Announcement

Collapse
No announcement yet.

DEBUG: ProcessMatches

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

  • DEBUG: ProcessMatches

    One request (From Peter Triggs) was around exposing the number of passes the AI uses to compare its armies against goals. This number is at present hard coded in Scheduler.cpp :
    Code:
    sint32 Scheduler::s_max_match_list_cycles = 6;
    I changed this line to
    Code:
    sint32 Scheduler::s_max_match_list_cycles = g_theConstDB->GetMaxMatchListCycles();
    And added to Constdb.h


    Code:
    	//added DWT 
    	sint32 m_max_match_list_cycles;
    
    
    	//added DWT
    	sint32 GetMaxMatchListCycles() const { return m_max_match_list_cycles; }
    Finally added to Constdb.cpp a new token TOKEN_MAX_MATCH_LIST_CYCLES, which corresponds to a const.txt name of MAX_MATCH_LIST_CYCLES.
    If I've done this all correctly, all you need to do is to add a new entry MAX_MATCH_LIST_CYCLES to Constdb.txt and you can set the number of passes to whatever you want.

    Hopefully I'll will receive the game soon to try this out myself!
    Attached Files

  • #2
    Thanks, NelsonandBronte,

    Now all I've got to get is MS VC++6 so that I can try this out.

    Comment


    • #3
      I had to remove a comma in ConstDB.cpp on line 916 and had to add an #include "ConstDB.h" to Scheduler.cpp to make the code to compile.

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

      Comment


      • #4
        Another problem I found is when I try run the game with this code is that the game crashs on startup.

        So I changed this line in Scheduler.cpp:

        Code:
        // added DWT
        sint32 Scheduler::s_max_match_list_cycles = 10;//= g_theConstDB->GetMaxMatchListCycles();
        And it does work but you can't set the max_match_list_cycles in Const.txt anymore. OK you can set it but without any effect.

        Obviously it is used before the database is loaded.

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

        Comment


        • #5
          Yeah, the static variable will be initialised right at the start of the program, before g_theConstDB will have been created.

          Fortunately, there is an easy solution. Because s_max_match_list_cycles is only referenced once, you may remove/bypass it completely, and replace the occurrence in CtpAi.cpp with a direct call to g_theConstDB->GetMaxMatchListCycles().

          At the time of the call, the database(s) will have been loaded.

          Comment


          • #6
            Actual I don't like this solution it would be better if it would be a static varable but then I can't initialize outside of a function or a constructor. So I came to this hack:

            Code:
            	if (g_theGameSettings->GetDifficulty() == (LEVELS_OF_DIFFICULTY - 1))
            		diff_cycles = 2;
            
            	//Modified by Martin Gühmann so that this can be exposed to const.txt
            	//if ( cycle < Scheduler::s_max_match_list_cycles + diff_cycles)
            	if ( cycle < g_theConstDB->GetMaxMatchListCycles() + diff_cycles)
            You can see that the DifficuiltDB is accessed everytime the code runs, so it shouldn't be such a big problem if the ConstDB is checked everytime. You can see on impossible the AI gets two extra cycles, well I would rather replace the diff cycles with the AI intelegence cycles from the DiffDB.

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

            Comment


            • #7
              Hi Martin,

              Did you include the wrong version of constDB.cpp in the altered source code update? After downloading, I got the "extra comma" problem that you reported some posts ago.

              Another problem is that this modification requires const.txt to be updated. Unfortunately, this does not only apply to the regular game (included in the update), but also to the scenarios.

              I think we have to add some mechanism to make the variables optional in const.txt, and use the original hardcoded value (6) when missing.
              Last edited by Fromafar; November 22, 2003, 14:53.

              Comment


              • #8
                Originally posted by Fromafar
                Hi Martin,

                Did you include the wrong version of constDB.cpp in the altered source code update? After downloading, I got the "extra comma" problem that you reported some posts ago.
                This is indeed right.

                Originally posted by Fromafar
                Another problem is that this modification requires const.txt to be updated. Unfortunately, this does not only apply to the regular game (included in the update), but also to the scenarios.

                I think we have to add some mechanism to make the variables optional in const.txt, and use the original hardcoded value (6) when missing.
                The problem is that there will be probably a lot of files that needs to be updated in the final version. For the standart scenarios we can provide the update with the patch itsself but for everything else it is up to the creators of the scenario, maybe we can support the most popular scenarios as well. For instance there is a slic file in the Magnificant Samurai scenario that contains a bug, so we have to do some work on them anyway. For other stuff for instance readding the rerouting trade button in the trade manager we need additional flag Freight in the tileimp.txt to give roads a Freight bonus. Also some other stuff that makes the game better should also be included the scenarios, so there will be stuff that works on the new patch and other stuff that don't work on the patch.

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

                Comment


                • #9
                  That doesn't stop us making the alterations optional - that should be possible, and in most cases it should be fairly easy.

                  Comment

                  Working...
                  X