Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing whitespace for skill point(s) #43

Closed
AmProsius opened this issue Jan 6, 2021 · 5 comments · Fixed by #98 or #365
Closed

Missing whitespace for skill point(s) #43

AmProsius opened this issue Jan 6, 2021 · 5 comments · Fixed by #98 or #365
Labels
compatibility: easy This issue is easy to make compatible. impl: replace str This issue requires replacing the content of strings. language dependent This issue only occurs in certain localizations. type: session fix The fix for this issues is persistent across a session.
Milestone

Comments

@AmProsius
Copy link
Owner

AmProsius commented Jan 6, 2021

When learning from teachers, there is a whitespace missing before "skill point" and "skill points" respectively.

@AmProsius AmProsius added this to To Do in v1.0.0 via automation Jan 6, 2021
@catalinstoian
Copy link

catalinstoian commented Jan 16, 2021

const string NAME_LearnPostfixS = "skill point)";
const string NAME_LearnPostfixP = "skill points)";

changed to

const string NAME_LearnPostfixS		=	" skill point)";	
const string NAME_LearnPostfixP		=	" skill points)";	

@szapp
Copy link
Collaborator

szapp commented Jan 24, 2021

This fix will be possible. However, it will only work if we know the exact wording for each language we want to support. If the wording is off by a little, or the values have been corrected, the fix would not take effect (which seems like a good option),

@szapp szapp added the type: session fix The fix for this issues is persistent across a session. label Jan 24, 2021
@AmProsius AmProsius added the language dependent This issue only occurs in certain localizations. label Jan 24, 2021
@AmProsius AmProsius changed the title Skill point amount not always correct Missing whitespace for skill point(s) Jan 25, 2021
@AmProsius
Copy link
Owner Author

This bug seems to be present for the English language version of the game only. If the fix doesn't take effect when a mod fixes these strings, that's fine.

@szapp szapp added the compatibility: easy This issue is easy to make compatible. label Jan 31, 2021
v1.0.0 automation moved this from To Do to Done Feb 2, 2021
AmProsius added a commit that referenced this issue Feb 2, 2021
#43: Fix whitespace of learning print (EN)
szapp added a commit that referenced this issue Feb 9, 2021
@AmProsius AmProsius added this to the v1.0.0 milestone Feb 9, 2021
@szapp szapp added this to Text constants in Fix templates Mar 15, 2021
@szapp szapp added impl: unknown There is no clear plan on how to implement this issue yet. impl: replace str This issue requires replacing the content of strings. and removed impl: unknown There is no clear plan on how to implement this issue yet. labels Mar 17, 2021
@szapp
Copy link
Collaborator

szapp commented Feb 3, 2022

This fix should be updated to use the G1CP string manipulation functions. In order to stick to only updating either both or none of the two string, the functions G1CP_GetStringConstId, G1CP_GetStringConstI, and G1CP_SetStringConstI should be used.

var int symb1Ptr; symb1Ptr = MEM_GetSymbol("NAME_LearnPostfixS");
var int symb2Ptr; symb2Ptr = MEM_GetSymbol("NAME_LearnPostfixP");
if (symb1Ptr) && (symb2Ptr) {
symb1Ptr = MEM_ReadInt(symb1Ptr + zCParSymbol_content_offset);
symb2Ptr = MEM_ReadInt(symb2Ptr + zCParSymbol_content_offset);
// Check if the strings are as expected
if (Hlp_StrCmp(MEM_ReadString(symb1Ptr), "skill point)"))
&& (Hlp_StrCmp(MEM_ReadString(symb2Ptr), "skill points)")) {
// Only then, fix them
MEM_WriteString(symb1Ptr, " skill point)");
MEM_WriteString(symb2Ptr, " skill points)");
return TRUE;
};
};
return FALSE;

changed to (something like):

    var int symb1Id; symb1Id = G1CP_GetStringConstId("NAME_LearnPostfixS", 0);
    var int symb2Id; symb2Id = G1CP_GetStringConstId("NAME_LearnPostfixP", 0);

    // Check if the strings are as expected
    if (Hlp_StrCmp(G1CP_GetStringConstI(symb1Id, 0, "G1CP invalid string"), "skill point)"))
    && (Hlp_StrCmp(G1CP_GetStringConstI(symb2Id, 0, "G1CP invalid string"), "skill points)")) {

        // Only then, fix them
        G1CP_SetStringConstI(symb1Id, 0, " skill point)");
        G1CP_SetStringConstI(symb2Id, 0, " skill points)");

        return TRUE;
    };

    return FALSE;

@szapp szapp reopened this Feb 3, 2022
@szapp szapp added this to To Do in v1.3.0 via automation Feb 3, 2022
@szapp szapp moved this from To Do to In Progress in v1.3.0 Feb 3, 2022
@AmProsius
Copy link
Owner Author

AmProsius commented Jan 10, 2023

I suggest splitting this fix into separate Fixes and refactor them like this:

G1CP_ReplaceStringConst("NAME_LearnPostfixS", "skill point)", " skill point)");

/*
 * Find a constant string (case-sensitive) and replace it if found. Returns true on success.
 */
func int G1CP_ReplaceStringConst(var string name, var string needle, var string replace) {
    if (STR_Compare(G1CP_GetStringConst(name, 0, "G1CP invalid string"), needle) != STR_EQUAL) {
        return FALSE;
    };

    G1CP_SetStringConst(name, 0, replace);
    return TRUE;
};

Alternatively, we could refactor this and leave both into one fix:

G1CP_ReplaceStringConst("NAME_LearnPostfixS", "skill point)", " skill point)");
G1CP_ReplaceStringConst("NAME_LearnPostfixP", "skill points)", " skill points)");

AmProsius added a commit that referenced this issue Mar 21, 2024
v1.3.0 automation moved this from In Progress to Done Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility: easy This issue is easy to make compatible. impl: replace str This issue requires replacing the content of strings. language dependent This issue only occurs in certain localizations. type: session fix The fix for this issues is persistent across a session.
Projects
Fix templates
Replace text constant
v1.3.0
  
Done
v1.0.0
  
Done
3 participants