diff --git a/TemplePlus/feat.cpp b/TemplePlus/feat.cpp index 56752ff7c..083ff479b 100644 --- a/TemplePlus/feat.cpp +++ b/TemplePlus/feat.cpp @@ -905,7 +905,10 @@ uint32_t _FeatPrereqsCheck(objHndl objHnd, feat_enums featIdx, feat_enums * feat else if (featReqCode == 266) { #pragma region BAB Requirement - if ((int) templeFuncs.ObjGetBABAfterLevelling(objHnd, classCodeBeingLevelledUp) < featReqCodeArg){ return 0; } + auto babAfterLvl = critterSys.GetBaseAttackBonus(objHnd, classCodeBeingLevelledUp); + if (babAfterLvl < featReqCodeArg) + return 0; + // if ((int) templeFuncs.ObjGetBABAfterLevelling(objHnd, classCodeBeingLevelledUp) < featReqCodeArg){ return 0; } #pragma endregion } else if (featReqCode >= stat_strength && featReqCode <= stat_charisma) diff --git a/TemplePlus/fonts/fonts.h b/TemplePlus/fonts/fonts.h index 23b540ab8..f6eac8ca5 100644 --- a/TemplePlus/fonts/fonts.h +++ b/TemplePlus/fonts/fonts.h @@ -46,6 +46,7 @@ Separates a block of text given flags into words split up on lines and renders them. */ class TextLayouter { + friend class FontRenderer; public: TextLayouter(gfx::RenderingDevice& device, gfx::ShapeRenderer2d& shapeRenderer); ~TextLayouter(); @@ -56,7 +57,7 @@ class TextLayouter { private: void DrawBackgroundOrOutline(const TigRect& rect, const TigTextStyle& style); - int GetGlyphIdx(char ch, const char *text) const; + static int GetGlyphIdx(char ch, const char *text); ScanWordResult ScanWord(const char* text, int firstIdx, int textLength, diff --git a/TemplePlus/fonts/fonts_layout.cpp b/TemplePlus/fonts/fonts_layout.cpp index 3c84e4c74..47477204c 100644 --- a/TemplePlus/fonts/fonts_layout.cpp +++ b/TemplePlus/fonts/fonts_layout.cpp @@ -271,7 +271,7 @@ void TextLayouter::DrawBackgroundOrOutline(const TigRect& rect, const TigTextSty } -int TextLayouter::GetGlyphIdx(char ch, const char* text) const { +int TextLayouter::GetGlyphIdx(char ch, const char* text) { // First character found in the FNT files constexpr auto FirstFontChar = '!'; @@ -281,11 +281,43 @@ int TextLayouter::GetGlyphIdx(char ch, const char* text) const { auto glyphIdx = ch - FirstFontChar; + auto chUns = (unsigned char)ch; + if (chUns <= (unsigned char)'~') + return glyphIdx; + if (tig_font_is_english) { - - if ( (unsigned char)ch >= FirstNonEnglish){ - glyphIdx = (unsigned char)ch - ( (unsigned char)FirstNonEnglish - FirstNonEnglishIdx); + + if (chUns >= FirstNonEnglish) { + glyphIdx = chUns - ((unsigned char)FirstNonEnglish - FirstNonEnglishIdx); + } + else + { + switch(chUns) + { + case 0x82: + return GetGlyphIdx(',', text); + case 0x83: + return GetGlyphIdx('f', text); + case 0x84: + return GetGlyphIdx(',', text); + case 0x85: // elipsis + return GetGlyphIdx(';', text); + case 0x91: + case 0x92: + return GetGlyphIdx('\'', text); + case 0x93: + case 0x94: + return GetGlyphIdx('"', text); + case 0x95: + return GetGlyphIdx('·', text); + case 0x96: + case 0x97: + return GetGlyphIdx('-', text); + default: + return GetGlyphIdx(' ', text); // speak english or die!!! + } } + if ((glyphIdx < -1 || ch > '~') && ch != '\n') { logger->warn("Tried to display character {} in text '{}'", glyphIdx, text); glyphIdx = -1; diff --git a/TemplePlus/fonts/fonts_render.cpp b/TemplePlus/fonts/fonts_render.cpp index ffd26edc7..8a9005b78 100644 --- a/TemplePlus/fonts/fonts_render.cpp +++ b/TemplePlus/fonts/fonts_render.cpp @@ -15,6 +15,7 @@ using namespace gfx; // First character found in the FNT files constexpr auto FirstFontChar = '!'; +const unsigned char FirstNonEnglishIdx = 92; #pragma pack(push, 1) struct GlyphVertex2d { @@ -145,7 +146,7 @@ void FontRenderer::RenderRun(cstring_span<> text, continue; } - auto glyphIdx = *it - FirstFontChar; + auto glyphIdx = TextLayouter::GetGlyphIdx(*it, nullptr); //*it - FirstFontChar; if ((unsigned char)*it == 0x20) { glyphIdx = '-' - '!'; diff --git a/tpdata/tprules/feat_properties.tab b/tpdata/tprules/feat_properties.tab index a046eb298..39e4c959d 100644 --- a/tpdata/tprules/feat_properties.tab +++ b/tpdata/tprules/feat_properties.tab @@ -652,7 +652,7 @@ 651 Improved Critical 524290 266 8 -1 -1 0 0 0 0 -1 0 0 0 0 0 0 0 652 Martial Weapon Proficiency 524290 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 653 Skill Focus 524290 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -654 Weapon Finesse 524290 -1 -1 581 1 587 2 588 1 221 5 -1 -1 0 0 0 0 +654 Weapon Finesse 524290 266 1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 655 Weapon Focus 524290 266 1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 656 Greater Weapon Focus 524290 11 4 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 657 Weapon Specialization 524290 11 8 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0