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

Government Modding Error with Reputation Keyword #9953

Closed
1 task done
xxxyyyqqq12345 opened this issue Mar 30, 2024 · 3 comments
Closed
1 task done

Government Modding Error with Reputation Keyword #9953

xxxyyyqqq12345 opened this issue Mar 30, 2024 · 3 comments
Labels
bug Something in the game is not behaving as intended
Milestone

Comments

@xxxyyyqqq12345
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Creating a government with keyword reputation give an error.
Ex:

government "Test gov"
	reputation
		"player reputation" -1000
		min -1000
		max -1000

returns the following error:
Error: Requested token index (1) is out of bounds:
file (file location)
LXX: government "Test gov"
LXX: reputation

This is probably caused by error in Government.cpp (line 225), where during the handling of reputation "child" is used instead of "grand".
Code in question:
for(const DataNode &grand : child)
{
const string &grandKey = grand.Token(0);
bool hasGrandValue = grand.Size() >= 2;
if(grandKey == "player reputation" && hasGrandValue)
initialPlayerReputation = add ? initialPlayerReputation + child.Value(valueIndex) : child.Value(valueIndex);
...

This cause the code to look to a value that follows "reputation" instead of "player reputation". Consequently, the following code works with no error:

government "Test gov"
	reputation -1000
		"player reputation" -1000
		min -1000
		max -1000

Steps to Reproduce

  1. Make a mode using the following government:
government "Test gov"
	reputation
		"player reputation" -1000
		min -1000
		max -1000
  1. See error when loading the game

Expected Behavior

According to the wiki, the following is the expect behavior:
reputation
"player reputation" <initial-rep#>
min <minimum-rep#>
max <maximum-rep#>

Screenshots

No response

Link to save file

No response

Operating System

Windows

Game Source

GitHub Releases

Game Version

current

Additional Information

No response

@xxxyyyqqq12345 xxxyyyqqq12345 added bug Something in the game is not behaving as intended unconfirmed More information is needed to be sure this report is true labels Mar 30, 2024
@TomGoodIdea
Copy link
Member

I can reproduce with the test data provided.

Your proposed change makes sense, feel free to open a fix PR.

@xxxyyyqqq12345
Copy link
Contributor Author

A new Pull Request have been made.
#9954

@Hecter94 Hecter94 removed the unconfirmed More information is needed to be sure this report is true label Mar 30, 2024
@Amazinite
Copy link
Collaborator

Nice find.

@warp-core warp-core added this to the 0.10.7 milestone Mar 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something in the game is not behaving as intended
Projects
None yet
Development

No branches or pull requests

5 participants