Announcement

Collapse
No announcement yet.

DEBUG: Prevented cities from revolting twice in a row

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • DEBUG: Prevented cities from revolting twice in a row

    * Prevented cities from revolting twice in a row (so if you have the wonder that gives you revolting cities, you'll at least have a chance to hold onto them)

    Any ideas on this one?

    i figure that we need to set a flag if the city revolts, and then check it when a city is about to revolt.

    any ideas to how, where and when?

  • #2
    Not sure exactly, but all the bits should be inplace to do something like this(hapiness level/trigger revolt etc - just to count the revolts).
    'The very basis of the liberal idea – the belief of individual freedom is what causes the chaos' - William Kristol, son of the founder of neo-conservitivism, talking about neo-con ideology and its agenda for you.info here. prove me wrong.

    Bush's Republican=Neo-con for all intent and purpose. be afraid.

    Comment


    • #3
      Re: DEBUG: Prevented cities from revolting twice in a row

      Originally posted by kaan
      i figure that we need to set a flag if the city revolts, and then check it when a city is about to revolt.

      any ideas to how, where and when?
      The idea looks fine to me. Probable locations are CityData::Revolt to set the flag, and CityData::ShouldRevolt to return FALSE and clear it when the flag has been set.

      The main problem is finding out where the flag is saved. We would need to have a save file from a patch-1.1 game at just the right spot to verify this. For SP, the best test set-up would be to have player 1 = human, player 2 = owner of the Egalitarian Act, and player 3 = original owner of the revolting city. The save file (at player 1's turn) should have the flag set for the revolting city, which is owned by player 2 by then. Maybe this is what the m_unknown_from_patch member variable is used for?

      Comment


      • #4
        I made changes to 3 files.

        CityData.cpp
        CityData.h
        Player.cpp

        First of all I renamed m_unknown_from_patch to m_last_turn_revolt in anticipation that this really is the true meaning for that variable.

        I added a check in CityData::ShouldRevolt to return false if there were a revolt last turn.

        I added setting m_last_turn_revolt to 1 at the end of CityData::Revolt.

        Last but not least i opted to add a neutralization function to CityData and call it from Player::AttemptRevolt if the city didnt revolt.

        I choose this method because CityData::ShouldRevolt might be called more than once or from other places, if not now then it might in the future (think slic).
        Now I only have a slight problem, i dont have VS6 installed
        Is there anyone who want to compile and test this peice of code for me?

        Thanks in advance
        klaus
        Attached Files
        Last edited by kaan; July 3, 2004, 06:09.

        Comment


        • #5
          You still have to put a declaration of the noRevolt member function in CityData.h to make it compile. After that, it seems to do the job.

          Separating the testing and the clearing of the flag is a good idea.

          The role and naming of the variables/constants/functions may require some more thought. If it is going to be a simple flag, I would prefer m_last_turn_revolt to be a bool (using true/false), and do the conversion to uint8 only when saving/restoring. Alternatively, it could be designed to be the number of guaranteed revolt free turns left, decremented each turn until it reaches 0. But then, I would prefer the "noRevolt" function to be named differently. And anyway, have it start with a capital first letter because that is the de facto convention for function names.

          Comment


          • #6
            I think that is a very good idea Fromafar.
            That is the idea that we have the possibility to decide how many turns instead of just a BOOL.
            So i implemented it and exposed the value in const.txt and this is the result.

            As before i still dont have a compiler at hand so please test it for me

            affected files :

            .\ctp2_code\gs\database\ConstDB.cpp
            .\ctp2_code\gs\database\ConstDB.h
            .\ctp2_code\gs\gameobj\CityData.cpp
            .\ctp2_code\gs\gameobj\CityData.h
            .\ctp2_code\gs\gameobj\Player.cpp
            .\ctp2_data\default\gamedata\Const.txt
            .\Scenarios\AlexanderTheGreat\scen0000\default\gam edata\Const.txt

            All files are based on the files from 2004.06.05.CTP2.All.zip
            Attached Files

            Comment


            • #7
              Originally posted by kaan
              As before i still dont have a compiler at hand so please test it for me
              And so far you wasn't able to compile it on VC++ 7. Or you don't even have this on hand.

              -Martin
              Civ2 military advisor: "No complaints, Sir!"

              Comment


              • #8
                Originally posted by Martin Gühmann


                And so far you wasn't able to compile it on VC++ 7. Or you don't even have this on hand.

                -Martin
                i just started to assemble the requred files last night
                one hell of a download those directX files.
                I will try to compile in .NET sometime later tonight.

                Comment


                • #9
                  It seems to be in fine working order, i have polished a bit on the comments and im submitting it to "altered source files" now.

                  Comment


                  • #10
                    Confirming the working part. I do have a request, though. Could you change it so the new value goes to the end of the list, and use a default value of 1 when the value is not found in const.txt? This could save us a lot of work.

                    I know this is only a partial fix, as you would still get the missing keword (sic) pop-up. However, you will at least be able to continue the game without having to find and update the const.txt files for all the existing mods and scenarios.

                    Eventually, we have to change the input file parser to make updating easier. But that would take more time.

                    Comment


                    • #11
                      Originally posted by Fromafar
                      Confirming the working part. I do have a request, though. Could you change it so the new value goes to the end of the list, and use a default value of 1 when the value is not found in const.txt? This could save us a lot of work.

                      I know this is only a partial fix, as you would still get the missing keword (sic) pop-up. However, you will at least be able to continue the game without having to find and update the const.txt files for all the existing mods and scenarios.

                      Eventually, we have to change the input file parser to make updating easier. But that would take more time.
                      ill look into it, if possible i will do the same to the previus modification of constDB.

                      Comment


                      • #12
                        I have discovered why there is a folder called database and a folder called newdb

                        ConstDB.cpp rely on Token.cpp to do the parsing of const.txt
                        Token.cpp seems to originate from ctp1 and provides no way to peek ahead when parsing (it is a very basic parser).

                        The best way to get optional values in const.txt would probably be to convert ConstDB.cpp to the newdb format with lexers and all that.
                        As that would reach far beyond the scope of this bugfix i will leave it here and maybe look at it again in the future.


                        I did move the new variables to the end of const.txt but no other changes was made.
                        Attached Files

                        Comment

                        Working...
                        X