From f7a1fb3978e3b64e94921cb00a4805165d31383f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 8 Apr 2008 17:25:19 +0000 Subject: [PATCH] - Removed some unnecessary morphing code. - Fixed some bugs in the HIRESTEX parser. - Added floating point support and #include and #define tokens to FParseContext Not used yet. - replaced the value scanning code in FParseContext::GetToken with calls to strtol. SVN r893 (trunk) --- docs/rh-log.txt | 6 +++ src/g_heretic/a_hereticartifacts.cpp | 4 -- src/g_raven/a_artitele.cpp | 7 +--- src/parsecontext.cpp | 62 ++++++++++++++-------------- src/parsecontext.h | 7 +++- src/textures/texturemanager.cpp | 5 ++- src/xlat/parse_xlat.cpp | 1 + src/xlat/xlat_parser.y | 3 +- 8 files changed, 50 insertions(+), 45 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 9fa78bba4b..1408e3affa 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,10 @@ April 8, 2008 (Changes by Graf Zahl) +- Removed some unnecessary morphing code. +- Fixed some bugs in the HIRESTEX parser. +- Added floating point support and #include and #define tokens to + FParseContext Not used yet. +- replaced the value scanning code in FParseContext::GetToken with + calls to strtol. - Changed XlatParseContext::FindToken to do a binary search over the valid token names. - Fixed: The check arrays for BlockThingsIterators were not properly diff --git a/src/g_heretic/a_hereticartifacts.cpp b/src/g_heretic/a_hereticartifacts.cpp index a8fe2b2fda..ab1c3a88f6 100644 --- a/src/g_heretic/a_hereticartifacts.cpp +++ b/src/g_heretic/a_hereticartifacts.cpp @@ -40,10 +40,6 @@ bool AArtiTomeOfPower::Use (bool pickup) } else { // Succeeded - Owner->player->morphTics = 0; - Owner->player->MorphedPlayerClass = 0; - Owner->player->MorphStyle = 0; - Owner->player->MorphExitFlash = NULL; S_Sound (Owner, CHAN_VOICE, "*evillaugh", 1, ATTN_IDLE); } return true; diff --git a/src/g_raven/a_artitele.cpp b/src/g_raven/a_artitele.cpp index c1242829f0..54252d0cba 100644 --- a/src/g_raven/a_artitele.cpp +++ b/src/g_raven/a_artitele.cpp @@ -61,12 +61,7 @@ bool AArtiTeleport::Use (bool pickup) P_Teleport (Owner, destX, destY, ONFLOORZ, destAngle, true, true, false); if (Owner->player->morphTics && (Owner->player->MorphStyle & MORPH_UNDOBYCHAOSDEVICE)) { // Teleporting away will undo any morph effects (pig) - if (P_UndoPlayerMorph (Owner->player)) - { - Owner->player->MorphedPlayerClass = 0; - Owner->player->MorphStyle = 0; - Owner->player->MorphExitFlash = NULL; - } + P_UndoPlayerMorph (Owner->player); } // The game check is not necessary because only Heretic defines *evillaugh by default // However if it is there no other game can use it if it wants to. diff --git a/src/parsecontext.cpp b/src/parsecontext.cpp index 3a801d5170..5b764d9547 100644 --- a/src/parsecontext.cpp +++ b/src/parsecontext.cpp @@ -103,41 +103,29 @@ loop: c = *sourcep++; if (c == 'x' || c == 'X') { - for (;;) - { - c = *sourcep++; - if (isdigit (c)) - { - buildup = (buildup<<4) + c - '0'; - } - else if (c >= 'a' && c <= 'f') - { - buildup = (buildup<<4) + c - 'a' + 10; - } - else if (c >= 'A' && c <= 'F') - { - buildup = (buildup<<4) + c - 'A' + 10; - } - else - { - sourcep--; - yylval->val = buildup; - return TokenTrans[NUM]; - } - } + yylval->val = (int)strtol(sourcep, &sourcep, 16); + return TokenTrans[NUM]; } else { sourcep--; } } - while (isdigit (c = *sourcep++)) - { - buildup = buildup*10 + c - '0'; - } + char *endp; + sourcep--; - yylval->val = buildup; - return TokenTrans[NUM]; + yylval->val = (int)strtol(sourcep, &endp, 10); + if (*endp == '.') + { + // It's a float + yylval->fval = strtod(sourcep, &sourcep); + return TokenTrans[FLOATVAL]; + } + else + { + sourcep = endp; + return TokenTrans[NUM]; + } } if (isalpha (c)) { @@ -162,7 +150,8 @@ loop: } if (FindSym (token, &yylval->symval)) { - return TokenTrans[SYMNUM]; + yylval->val = yylval->symval->Value; + return TokenTrans[NUM]; } if ((yylval->val = P_FindLineSpecial(token)) != 0) { @@ -173,7 +162,7 @@ loop: } if (c == '/') { - c = *sourcep++;; + c = *sourcep++; if (c == '*') { for (;;) @@ -258,6 +247,19 @@ loop: c--; return 0; } + if (c == '#') + { + if (!strnicmp(sourcep, "include", 7)) + { + sourcep+=7; + return TokenTrans[INCLUDE]; + } + if (!strnicmp(sourcep, "define", 6)) + { + sourcep+=6; + return TokenTrans[DEFINE]; + } + } switch (c) { case '^': return TokenTrans[XOR]; diff --git a/src/parsecontext.h b/src/parsecontext.h index 06ecb75393..c7627f3634 100644 --- a/src/parsecontext.h +++ b/src/parsecontext.h @@ -48,7 +48,7 @@ enum MULTIPLY , DIVIDE , NUM , - SYMNUM , + FLOATVAL , LPAREN , RPAREN , SYM , @@ -65,6 +65,7 @@ enum RSHASSIGN, STRING , INCLUDE , + DEFINE , }; #define DEFINE_TOKEN_TRANS(prefix) \ @@ -78,7 +79,7 @@ enum prefix##MULTIPLY, \ prefix##DIVIDE, \ prefix##NUM, \ - prefix##SYMNUM, \ + prefix##FLOATVAL, \ prefix##LPAREN, \ prefix##RPAREN, \ prefix##SYM, \ @@ -95,6 +96,7 @@ enum prefix##RSHASSIGN, \ prefix##STRING, \ prefix##INCLUDE, \ + prefix##DEFINE, \ }; @@ -107,6 +109,7 @@ struct FParseSymbol union FParseToken { int val; + double fval; char sym[80]; char string[80]; FParseSymbol *symval; diff --git a/src/textures/texturemanager.cpp b/src/textures/texturemanager.cpp index fd428d1dd7..432db37981 100644 --- a/src/textures/texturemanager.cpp +++ b/src/textures/texturemanager.cpp @@ -45,6 +45,7 @@ #include "sc_man.h" #include "gi.h" #include "st_start.h" +#include "cmdlib.h" extern void R_InitBuildTiles(); @@ -521,6 +522,8 @@ void FTextureManager::LoadHiresTex(int wadnum) else if (sc.Compare("sprite")) type=FTexture::TEX_Sprite, mode=0; else type = FTexture::TEX_Any, mode = 0; + if (type != FTexture::TEX_Any) sc.MustGetString(); + sc.String[8]=0; tlist.Clear(); @@ -577,7 +580,7 @@ void FTextureManager::LoadHiresTex(int wadnum) else if (sc.Compare("define")) // define a new "fake" texture { sc.GetString(); - memcpy(src, sc.String, 8); + memcpy(src, ExtractFileBase(sc.String, false), 8); int lumpnum = Wads.CheckNumForFullName(sc.String, true, ns_graphics); diff --git a/src/xlat/parse_xlat.cpp b/src/xlat/parse_xlat.cpp index 998fb11616..ed377b0c36 100644 --- a/src/xlat/parse_xlat.cpp +++ b/src/xlat/parse_xlat.cpp @@ -51,6 +51,7 @@ enum { XLAT_INCLUDE=128, XLAT_STRING, + XLAT_FLOATVAL, // floats are not used by the grammar }; DEFINE_TOKEN_TRANS(XLAT_) diff --git a/src/xlat/xlat_parser.y b/src/xlat/xlat_parser.y index 1d35ab5870..7f47f45da7 100644 --- a/src/xlat/xlat_parser.y +++ b/src/xlat/xlat_parser.y @@ -30,11 +30,10 @@ external_declaration ::= NOP. %type exp {int} exp(A) ::= NUM(B). { A = B.val; } -exp(A) ::= SYMNUM(B). { A = B.symval->Value; } exp(A) ::= exp(B) PLUS exp(C). { A = B + C; } exp(A) ::= exp(B) MINUS exp(C). { A = B - C; } exp(A) ::= exp(B) MULTIPLY exp(C). { A = B * C; } -exp(A) ::= exp(B) DIVIDE exp(C). { A = B / C; } +exp(A) ::= exp(B) DIVIDE exp(C). { if (C != 0) A = B / C; else context->PrintError("Division by Zero"); } exp(A) ::= exp(B) OR exp(C). { A = B | C; } exp(A) ::= exp(B) AND exp(C). { A = B & C; } exp(A) ::= exp(B) XOR exp(C). { A = B ^ C; }