Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Political bug in r852? (Human rights-specific? Probably not...)  (Read 1687 times)

Lielac

  • Bay Watcher
  • [ETHIC:PEDANTRY: PERSONAL_MATTER]
    • View Profile
Political bug in r852? (Human rights-specific? Probably not...)
« on: September 20, 2014, 10:27:22 pm »

Okay. I'm playing revision 852, and something straaaaaaaaange has happened with Human Rights. In the Liberal Agenda summary window it's yellow with a red background, and there's no yellow O on the slider. In the Issues B tab, the text for Human Rights is also yellow-on-red and says, "The nation is a respected international leader on Moral Interrogation Practices."

Now, on to what caught my eye as weird: Congress votes, completely unanimously, to push Human Rights farther C+, even though they're moderate. And the L President condones this. But nothing changes! Noooooothiiiiiiiing. What the heck?

I've defeated 2/3 CCS safehouses, am playing with National LCS, and have not turned on SCS. Everything else is default, and I'm pretty sure keeping music off wouldn't affect the game to such a strange degree. Is the game trying to guilt-trip me for all the CCS vigilantes I've beaten up in the pursuit of the Liberal utopia? They're the bad guys, it's justifiiiiiiied

Edit: I copied the save.dat for my r852 version. Also, a month or so in-game after that, I've got the /public/ voting 53-47 to push Human Rights into the C's, /and/ congress being weird, but still no change.

Edit2: It's 2021 in-game, there's a L+ president, and /she's/ condoning it too. wHAT THE FRIG. And nothing else L+ has gone buggy, even though I have like half a dozen.

Edit3: It's 2024, the Congress amendment has gone through, all laws are L+ except Human Rights, and they're /still/ voting monthly to make Human Rights C+. WHAT. THE. FRIG. (I made a new save.dat copy.)

Edit4: Made another save.dat copy after the '24 presidental election. Both amendments have gone through. Here's the file on Dropbox: https://www.dropbox.com/s/m5ed97wx0r3k72c/just%20why.dat?dl=1

Edit5: I disbanded the LCS, and after a couple of years the Human Rights thing worked itself out. It flashed to red and then to green.
« Last Edit: September 21, 2014, 01:54:07 am by Lielac »
Logged


Lielac likes adamantine, magnetite, marble, the color olive green, battle axes, cats for their aloofness, dragons for their terrible majesty, women for their beauty, and the Oxford comma for its disambiguating properties. When possible, she prefers to consume pear cider and nectarines. She absolutely detests kobolds.

Liberal Elitist

  • Bay Watcher
  • I'm more liberal than you are!
    • View Profile
    • The Liberal Crime Squad wiki
Re: Political bug in r852? (Human rights-specific? Probably not...)
« Reply #1 on: September 22, 2014, 04:22:19 am »

Ah, yellow text on a red background for text that goes with an alignment indicates an error (it indicates the text is outside of the range from -3 to 2, with -3 being Stalinist, -2 being Arch-Conservative, -1 being regular Conservative, 0 being moderate, 1 being regular Liberal, and 2 being Elite Liberal). The code for that is in void set_alignment_color(signed char alignment, bool extended_range) in commondisplay.cpp, right near the beginning of the file.

So somehow the alignment number for your Human Rights issue was corrupted, and the color of the text indicated this was an error.

Well, the Human Rights/LAW_TORTURE issue is the LAST issue in the Laws enum prior to LAWNUM, and it's the LAST issue in the law[] array. Immediately AFTER the law[] array in a saved game, if you look at saveload.cpp, is the house[] array, and then the senate[] array.

So my hypothesis is, this is a bug, and somehow, someone set house[-1]. No wait, if someone set house[-1], members of the House, Senate, Supreme Court, and Executive Branch all have alignments in the range from -3 to +2. So for it to be out of that range, something else would have to happen. And although they, by their very nature, probably ought to be against the rules of the language, negative array indices are allowed in C and C++.

I don't know what happened. But it is very likely to involve house[-1] being set to some strange number.

It is possible this may have happened due to an incompatibility between different SVN revisions and might not be a bug. Maybe you started the game in one SVN revision, updated to a newer version of the game, and then continued playing, thus causing a bug to occur because the 2 revisions have incompatible savegame formats. For instance if you had a revision prior to 846 and updated to revision 852 this kind of thing would be likely.

But in the REAL world, I am going on a month-long vacation to Europe tomorrow and won't be online much or at all, and won't have the computer I do programming on with me. I have done some preliminary looking at code to see what might have caused this and from looking at saveload.cpp it's likely that there is code that accesses the array house[] with an index of -1, which would correspond to accessing the array law[] with an index of LAW_TORTURE. Well those are their orders in the savegame anyway, but maybe their orders in memory are different while the program is running... ah yes, the orders of variables in memory are in game.cpp (declared externally in externs.h). Ah, in game.cpp, the house[] array comes right after the law[] array, the same exact order.

So this means that house[-1] and law[LAW_TORTURE] are actually the same variable, and any code that modifies one of them modifies the other.

Now, we do have code to deal with Stalinist elected officials (a value of -3 alignment), but for laws, the alignment range is smaller by 1, from -2 to +2.

So hypothetically if a Stalinist were elected to the House in position -1, this would set law[LAW_TORTURE] to -3, outside the -2 to +2 range it should be in... the initial error being a negative array index for house[].

Then the next error to occur would be, the code dealing with laws doesn't consider the possibility that laws might be outside the range from -2 to +2, and assumes they are in the range from -2 to +2, so if they are outside that range, there is no way for the game to recover from this bug, it will just continue (although if it is also outside the -3 to +2 range, it will have a color to indicate an error).

Now you've said the issue gets pushed further and further C+ no matter what. This makes sense since that's probably the last option in a case of if...else statements, regarding the alignment of a law.

Also the Moral Interrogation Practices text is likewise the last option in a bunch of if...else statements, regarding the alignment of a law.

So, logically, the initial cause of this bug is that somewhere, in election code or something like that, the house array with an index of -1 is being set. Of course the compiler doesn't catch this at compile time since obviously a variable is being used as the array index instead of a constant, and the compiler doesn't know what value the array will have at runtime. But somewhere, a variable or expression equal to -1 is used as the array index for the house[] array when setting it, most likely in code for an election. And this is causing these other errors in the game to occur, as a logical consequence. This other behavior, after the initial error, is actually somewhat good, because it makes it obvious that an error has occurred, and gives many clues how to catch it.

Now I have looked through the code for every single instance of where the house[] array has its elements set, and I don't see any instances of this which are obvious. There are many instances where it is set as part of a loop like this: for(int h=0;h<HOUSENUM;h++). And then house[h] is set. This is harmless if you assume that the variable h is not modified by any other code inside the loop. However some of these loops are longer and might contain code that modifies the loop variable (for instance if it said "h--" somewhere, that would be bad). Anyway I haven't quite found the exact cause of the bug but I am pretty sure it is due to these factors.

But again this isn't necessarily a bug, it is possible it is just a savegame incompatibility between different versions. Unless of course you created the game and played the entire game on the same revision (852 you said), in which case it most certainly IS a bug. But I think I have a good lead here as to what it is. Unfortunately I will be going on vacation tomorrow so I hope somebody else follows up on the leads I have here and the evidence we already have about what is probably causing this (the house[] array being called with an index of -1 somewhere).

Well Lielac you did a good job documenting this bug in detail, we have plenty of info to go on already. But I will be busy today packing for my trip, and I wasn't able to find where house[-1] is called during my cursory look through the code. So hopefully someone else will solve this. Also I haven't yet slept tonight and I have an appointment in a few hours, among other things in my busy schedule for my last day before my plane flight. I hope the debugging work I did here will help whoever looks at this problem next, since I haven't quite gotten this all the way solved, and of course, my hunch about the likely cause of this bug is just the most likely possibility in my mind but there could also be other possibilities.

And if this is just a run-of-the-mill savegame incompatibility caused by starting a game in one revision and then finishing it in another revision (if I recall correctly you downloaded revision 840 earlier, and then you say you have now upgraded to revision 852)... well if you had an ongoing savegame between those 2 revisions, the cause of this bug is the addition of a new variable called fieldskillrate to the game and to the save files. Actually I think this is most likely just a savegame incompatibility and you probably did start a game in revision 840 then finish it in revision 852. Nick Dumas in revision 846 specifically increased the version number of the game from 4.07.5 beta to 4.07.6 beta so that old savegames wouldn't be able to load, but then I reverted that change in revision 848 because savegame incompatibilities happen all the time between SVN revisions (just as every release version has incompatible savegames too), and because the most recent beta version is 4.07.4 beta which means the next one is 4.07.5 beta so if we increase it to 4.07.6 beta that's rather premature.

So this is probably just a savegame incompatibility between different SVN revisions of the game. I couldn't actually find any code that called law[-1] so I think savegame incompatibility is a more likely explanation, for now. Unless you can duplicate this bug again with a new game you start... but anyway I have a vacation tomorrow, I have a lot of packing to do today and even have to buy some stuff before I leave such as a belt (to keep my pants up... the belt I was using just broke yesterday), a laundry bag (to store dirty clothes while I'm on vacation and keep them separate from clean clothes), and some vitamins (I take both an iron-free multivitamin and Vitamin D and am almost out of both... it's best to get multivitamins without iron because iron is the easiest vitamin or mineral to overdose on and if you take too many regular multivitamin pills the iron overdose is the thing that'll get you sick first, so I take multivitamins without iron since they are safer, I do my research on everything), plus I have an appointment this morning (with someone with an LMSW after their name, good luck figuring out that stands for Licensed Master's in Social Work), and I have to go to sleep NOW... well not quite now, I have to take some laundry out of the washer and put it into the dryer first so it'll be dry for me to pack, as well as for me to wear to my appointment in the morning. :o
« Last Edit: September 22, 2014, 04:40:58 am by Liberal Elitist »
Logged
The Liberal Crime Squad wiki is your friend.

Quote from: Lielac
Edit: Figured it out via a little bit of trial and error and oH MY GOD WHAT IS THIS MUSIC WHAT IS THIS MUSIC WHAT THE HECK IS IT SPACEBALLS MUSIC? WHATEVER IT IS IT IS MAGICAL

Lielac

  • Bay Watcher
  • [ETHIC:PEDANTRY: PERSONAL_MATTER]
    • View Profile
Re: Political bug in r852? (Human rights-specific? Probably not...)
« Reply #2 on: September 22, 2014, 07:34:17 am »

Oh god so many words that I barely understand I am not a programmer I am merely a lowly roguelike player

Okay. To answer what I did understand:

1. I hope you have fun on your vacation! :D

2. I make a new game every time I move to a different version. My r852 game is completely separate from whatever I was doing in r840, so save incompatibility isn't the issue.

3. Once I get bored of screwing around in r854 Nightmare Mode, I'll prod r852 some more and see if I can remember what all I was doing to further the liberal agenda, in case it matters. Of course, that means I'd have to remember what I was doing, instead of just Disguising my way into the AM Radio Station and making noisy Liberal Agenda noises all over the air... but I have 4 different saves from various points in the process and only posted a link to the last one, I'mma put the first three on my dropbox too here's the folder with all four they're numbered in chronological order. Note the exhausted crankiness in the file names.

4. I don't think you asked about this, but I had LCS open for a long time and maybe that corrupted something. Also I copied the save.dat files without closing LCS first, and that miiiiiiight have corrupted the copies but I'm not sure.
Logged


Lielac likes adamantine, magnetite, marble, the color olive green, battle axes, cats for their aloofness, dragons for their terrible majesty, women for their beauty, and the Oxford comma for its disambiguating properties. When possible, she prefers to consume pear cider and nectarines. She absolutely detests kobolds.

Liberal Elitist

  • Bay Watcher
  • I'm more liberal than you are!
    • View Profile
    • The Liberal Crime Squad wiki
Re: Political bug in r852? (Human rights-specific? Probably not...)
« Reply #3 on: October 02, 2014, 04:10:35 pm »

Oh god so many words that I barely understand I am not a programmer I am merely a lowly roguelike player

Okay. To answer what I did understand:

1. I hope you have fun on your vacation! :D

2. I make a new game every time I move to a different version. My r852 game is completely separate from whatever I was doing in r840, so save incompatibility isn't the issue.

3. Once I get bored of screwing around in r854 Nightmare Mode, I'll prod r852 some more and see if I can remember what all I was doing to further the liberal agenda, in case it matters. Of course, that means I'd have to remember what I was doing, instead of just Disguising my way into the AM Radio Station and making noisy Liberal Agenda noises all over the air... but I have 4 different saves from various points in the process and only posted a link to the last one, I'mma put the first three on my dropbox too here's the folder with all four they're numbered in chronological order. Note the exhausted crankiness in the file names.

4. I don't think you asked about this, but I had LCS open for a long time and maybe that corrupted something. Also I copied the save.dat files without closing LCS first, and that miiiiiiight have corrupted the copies but I'm not sure.

Hmm, I am on vacation right now but I have the Internet right now and some spare time so I thought I'd visit the forums to check up on things. OK, I downloaded your savegames onto this low-power netbook I am traveling with. I will look at them later, probably after vacation. FYI, revisions 850-855 are all savegame-compatible with each other, so a savegame from any revision in the range 850-855 ought to work perfectly well with any other... in fact they all use the same executable files and source code, the changes in revisions 851-855 were to documentation files and stuff like that so they didn't introduce any savegame incompatibility with revision 850 savegames. But revision 849 and earlier savegames are not compatible with revision 850-855 savegames due to an XML change.

So anyway if those savegames are from revision 852 they should work perfectly fine with the latest revision 855.

Also it's obvious now that this is a bug in the game, not a savegame incompatibility, from what you've said. And nothing you did, like having the game running a long time, or copying save.dat files while it is running, ought to cause a problem. The save.dat files are saved once a game-day, so every time a new day starts in the game, the game is saved to disk... and they are also saved when exiting the game normally (but not if you click the X in the corner of the window with your mouse, then nothing is saved).

So yeah this is a bug that needs to be fixed but I am still on vacation and on a low power netbook with a tiny screen (1024x600 pixels) that isn't big enough to run an IDE for programming in, plus I don't have enough spare time right now to program until the vacation is over. Maybe someone else can take a look at fixing this bug. I don't think I'll be back home for another week or two, I don't know the exact date actually, but I think it's around October 14th which is almost 2 weeks from now. And I only have Internet access sometimes when I am here. The WiFi on this netbook does not work very well, in fact I had to buy an external WiFi adapter that connects by USB because the built-in one is so bad. Well anyway I will probably be back working on Liberal Crime Squad around the middle of this month and if nobody else fixes this bug I will try and see if I can fix it. It seems like an important one to fix.

Nothing you did seems like it would cause any problem, this is obviously a bug in the game. Maybe it is in saveload.cpp. That code handles saving and loading games but the code for both is separate and if they don't exactly match in terms of which variables are in what order and take up how many bytes, then there is a problem. The saving and loading functions in that source code file have to mirror each other exactly. I thought they did. Maybe they do, maybe they don't. I and other programmers will need to look into this more. It is either that code causing a bug, or the code related to politics. I thought maybe it was that code earlier, back when I posted in this thread before this vacation, but I couldn't find any problems... but it is still possible there is a negative array index being used with a variable as the array index (so the compiler doesn't notice a problem). Or maybe something else is the problem. But right now I am suspecting saveload.cpp of having a problem in it maybe. I will look into this matter as soon as I am back from vacation, around October 14, probably. Or maybe someone else will look into it sooner.

It IS an important bug to fix, after all. I think it is likely this bug was introduced recently by some recent revision... probably a revision in the 840s... less likely one in the 830s or earlier. Don't know for sure yet when it was introduced, it's possible this might be an old bug, just unlikely. But I do know this must be a bug in the game. Well I guess it could've been sitting around a bit longer, maybe since somewhere in the 700s revisions, but I REALLY doubt it would be from the 600s revisions or earlier. I think it might have something to do with the code about Stalinists in politics (even if you were not playing in Stalinist mode, this needs to be double-checked). Or the loading and saving games code. Or maybe some other code I didn't think of... I don't know where the bug is yet.

Well back to vacation, I need to go to bed soon or else I won't get enough sleep before the breakfast tomorrow morning here, you know, time zones and all that. I am 6 hours in the future from the East Coast of the United States, 9 hours in the future from the West Coast. :P
Logged
The Liberal Crime Squad wiki is your friend.

Quote from: Lielac
Edit: Figured it out via a little bit of trial and error and oH MY GOD WHAT IS THIS MUSIC WHAT IS THIS MUSIC WHAT THE HECK IS IT SPACEBALLS MUSIC? WHATEVER IT IS IT IS MAGICAL

SlatersQuest

  • Bay Watcher
    • View Profile
Re: Political bug in r852? (Human rights-specific? Probably not...)
« Reply #4 on: October 02, 2014, 09:50:48 pm »

Hi! Off topic, but I hope you're enjoying your vacation :)

Yeah, something got clobbered in the game somewhere. Were you playing on the TV mod by any chance? If so, there is a (fixed in the latest release) bug that might cause that.
Logged

Lielac

  • Bay Watcher
  • [ETHIC:PEDANTRY: PERSONAL_MATTER]
    • View Profile
Re: Political bug in r852? (Human rights-specific? Probably not...)
« Reply #5 on: October 03, 2014, 04:35:08 am »

Hi! Off topic, but I hope you're enjoying your vacation :)

Yeah, something got clobbered in the game somewhere. Were you playing on the TV mod by any chance? If so, there is a (fixed in the latest release) bug that might cause that.

Nope, vanilla as missionary sex. I'm not even sure how I'd install a mod, anyway.
Logged


Lielac likes adamantine, magnetite, marble, the color olive green, battle axes, cats for their aloofness, dragons for their terrible majesty, women for their beauty, and the Oxford comma for its disambiguating properties. When possible, she prefers to consume pear cider and nectarines. She absolutely detests kobolds.