Difference between revisions of "Testing Notepad"

From FreeOrionWiki
Jump to: navigation, search
m (the rest, edited)
m (Max Meter Value Condition Nonfunctional)
Line 247: Line 247:
 
This is fixed now. --Zach
 
This is fixed now. --Zach
  
===Max Meter Value Condition Nonfunctional===
 
 
Replace techs.xml with the following:
 
 
<pre>
 
<GG::XMLDoc>
 
<Category>LEARNING_CATEGORY</Category>
 
  <Tech>
 
    <name>LRN_PHYS_BRAIN</name>
 
    <description>LRN_PHYS_BRAIN_DESC</description>
 
    <type>TT_THEORY</type>
 
    <category>LEARNING_CATEGORY</category>
 
    <research_cost>10</research_cost>
 
    <research_turns>1</research_turns>
 
    <effects>
 
      <EffectsGroup>
 
        <scope>
 
          <Condition::MeterValue>
 
            <meter>METER_RESEARCH</meter>
 
            <low>24</low>
 
            <high>999</high>
 
            <max_meter>1</max_meter>
 
          </Condition::MeterValue>
 
        </scope>
 
        <activation>
 
          <Condition::Self/>
 
        </activation>
 
        <effects>
 
          <Effect::Destroy/>
 
        </effects>
 
      </EffectsGroup>
 
    </effects>
 
    <prerequisites></prerequisites>
 
    <unlocked_items></unlocked_items>
 
  </Tech>
 
</GG::XMLDoc>
 
</pre>
 
 
Start a game.  Do either A or B:
 
 
A) Set your planet's focus to research/research.  Research the tech.  End turn a few times.  Planet is not destroyed.
 
 
B) Research the tech immediately.  End turn a few times after getting it.  Set focus to research/research.  End turn a few times.  Planet is not destroyed.
 
 
In both cases A and B, open save the game and open up the file in a text editor.  Search for the name of your planet.  You should find something like the following for that planet (but with a different m_current value):
 
 
<pre>
 
<m_research>
 
  <Meter>
 
    <m_current>30</m_current>
 
    <m_max>30</m_max>
 
  </Meter>
 
</m_research>
 
</pre>
 
 
This indicates that the planet's max meter value is above 24 and below 999, which is specified in the effect as the minimum in the scope condition, so the planet should have been destroyed by the effect once the tech was researched.
 
 
This problem does not seem to occur with current meter values.
 
  
  

Revision as of 01:36, 26 May 2005

Unresolved Issues

Stockpile Condition Includes Unrelated Planets

Replace your techs.xml with this:

<?xml version="1.0"?>
 <GG::XMLDoc>
 <Category>LEARNING_CATEGORY</Category>
 <Tech>
   <name>STACKING_TEST</name>
   <description>STACKING_TEST_DESC</description>
   <type>TT_THEORY</type>
   <category>LEARNING_CATEGORY</category>
   <research_cost>3</research_cost>
   <research_turns>1</research_turns>
   <effects>
     <EffectsGroup>
       <scope>
         <Condition::EmpireStockpileValue>
           <stockpile>ST_FOOD</stockpile>
           <low>45</low>
           <high>999</high>
         </Condition::EmpireStockpileValue></scope>
       <activation><Condition::Self/></activation>
       <stacking_group>STACKTEST</stacking_group>
       <effects>
         <Effect::SetPlanetSize>SZ_TINY</Effect::SetPlanetSize>
       </effects>
     </EffectsGroup>
   </effects>
   <prerequisites></prerequisites>
   <unlocked_items></unlocked_items> 
 </Tech>
</GG::XMLDoc>

Start a game and set your homeworld to Farming/Farming focus, and research the tech. Send your ships to a system that has a planet that's not owned by any empire, either in a system that has an owned planet as well, or a system that has no owned planets. End your turn until you research the tech and build up your food stockpile. When the effect executes, apparently all planets (owned by you, or another empire, or unowned, regardless of system) have their size changed to SZ_TINY, when it should be just planets owned by the empire whose food stockpile is above 45.

AddOwner Effect Needs Tweaking...

Swap out your current techs.xml for the following:

<?xml version="1.0"?>
 <GG::XMLDoc>
 <Category>LEARNING_CATEGORY</Category>
  <Tech>
    <name>LRN_PHYS_BRAIN</name>
    <description>LRN_PHYS_BRAIN_DESC</description>
    <type>TT_THEORY</type>
    <category>LEARNING_CATEGORY</category>
    <research_cost>10</research_cost>
    <research_turns>1</research_turns>
    <effects>
      <EffectsGroup>
        <scope>
          <Condition::All/>
        </scope>
        <activation>
          <Condition::Self/>
        </activation>
        <effects>
          <Effect::AddOwner>Source.Owner</Effect::AddOwner>
        </effects>
      </EffectsGroup>
    </effects>
    <prerequisites></prerequisites>
    <unlocked_items></unlocked_items>
  </Tech>
</GG::XMLDoc>

Start a game, research the tech, end the turn.

A large number of sitrep reports are generated about your population at various planets having starved and that the planet is lost. This includes planets in systems you haven't explored and don't know the name of, which are reported as ERROR in the sitrep. You also gain control over all populated systems and all fleets in the game universe. However the previous owners still retain control as well, as can be seen on the map with multiple coloured system names.

Planets that have no population should not be fired upon by this effect, as they are incapable of being owned by a player without population on them. (If this is impossible, then these planets should get a default low population, though it would be much better to not have the effect fire on them).

Planets should also not have more than one owner ever. In the case when this effect fires on a planet which already has an owner, the previous owner should be removed.

I'm not sure why this effect is "AddOwner" and not "SetOwner"... Presumably it's for the potential future case where there might be something that can be owned by two or more players at a time. For now, and for planets (and ships and fleets), this doesn't make sense.

I'm not completely sure that more than one empire is owning the planets, as I'm just basing it off the multiple colouration of system names and lack of any other planets owned by another race in the system. Since there's no such multicolouring for fleets and ships, I'm not sure if a similar co-owning is occuring for them. If it is, then they should also not be possible to co-own between multiple players.

There can be multiple owners for systems, since multiple empires can colonize planets in the same system. There also could be joint ownership of planets (or even fleets, etc., who knows?) in a future version. Therefore, SetOwner will not work as an effect, in general. Again, this looks to me like just an Effect that does what it is supposed to do, if not what is desired. --Zach

UI Response...

After doing the above test case, you may notice that the UI response time slows drastically for scrolling the map or moving around the sitrep. I'm not sure if this is a bug or just a major bottleneck. In either case, it needs fixing. This probably occurs in other situations as well, but I haven't noticed it at any other time.

This is wierd and needs further investigation. -- Zach

Proportedly Resolved Issues

Setting MaxPopulation of Gas Giants / Asteriods

Replace techs.xml with this:

<?xml version="1.0"?>
 <GG::XMLDoc>

 <Category>LEARNING_CATEGORY</Category>

  <Tech>
    <name>LRN_PHYS_BRAIN</name>
    <description>LRN_PHYS_BRAIN_DESC</description>
    <type>TT_THEORY</type>
    <category>LEARNING_CATEGORY</category>
    <research_cost>10</research_cost>
    <research_turns>1</research_turns>
    <effects>
     <EffectsGroup>
       <scope>
         <Condition::All/>
       </scope>
       <activation><Condition::Self/></activation>
       <effects>
         <Effect::SetMeter>
           <meter>METER_POPULATION</meter>
           <value>Target.MaxPopulation + 1</value>
           <max>1</max>
         </Effect::SetMeter>
       </effects>
     </EffectsGroup>
    </effects>
    <prerequisites></prerequisites>
    <unlocked_items></unlocked_items>
  </Tech>
</GG::XMLDoc>

Start a new game, and research the tech. Find a gas giant or asteroid belt planet and colonize it (it should have MaxPopulation = 1 due to the effect). The colony starves to death on the next turn, even if you had enough food surplus available to feed it.

Discussion

This appears to be inevitable, because the helth meter is also 0. In any case, I don't think this is a bug, just a bad Effect. --Zach

If possible, I'd like to avoid requiring overly complicated effects and conditions to do do relatively simple things... Can we make colonizability and max population separate properties for popcentres / planets? Thus a gas giant / asteroid belt could receive its +1 to max pop, but players still wouldn't be able to colonize it...

Checks like this would be great if we had unlimited time, but such checks take a lot of time, and at some point we need the Effects writers just to be careful. No amount of in-code checking will undo a bad or misconceived Effect. --Zach

Set Current Population Effect Ineffective

Replace techs.xml with the following:

<?xml version="1.0"?>
 <GG::XMLDoc>
 <Category>LEARNING_CATEGORY</Category>
  <Tech>
    <name>LRN_PHYS_BRAIN</name>
    <description>LRN_PHYS_BRAIN_DESC</description>
    <type>TT_THEORY</type>
    <category>LEARNING_CATEGORY</category>
    <research_cost>10</research_cost>
    <research_turns>1</research_turns>
    <effects>
      <EffectsGroup>
        <scope>
          <Condition::Type>OBJ_PLANET</Condition::Type>
        </scope>
        <activation>
          <Condition::Self/>
        </activation>
        <effects>
          <Effect::SetMeter>
            <meter>METER_POPULATION</meter>
            <value>50</value>
            <max>0</max>
          </Effect::SetMeter>
        </effects>
      </EffectsGroup>
    </effects>
    <prerequisites></prerequisites>
    <unlocked_items></unlocked_items>
  </Tech>
</GG::XMLDoc>

Start a new game, research the tech, and end turn a few times.

The effect doesn't seem to fire on any planets, whether populated or not.

Move your colonly ship to another system and colonize another planet.

Still nothing happens.

The effect should set the current population of all planets (or preferably just populated planets) to 50.

Discussion

This Effect does in fact work properly, and does set the current pop to 50 on all planets. Planets with no owners do not have pop displayed, but it's there in the save file. Also, the current is set to 50, which is far higher than the max for most worlds, so no world will actually end up with current pop=50 at the end of a turn.

However, this did bring a bonafide bug to the surface. When setting the current value of a meter, I was clamping the new current value to the max value. This sounds fine, but in fact the max changes as different effects fire, so effects that set the current might be clamped to something less than the final max, if a max-expanding tech, special, etc. ups the max later. This has been fixed. --Zach

In my tests, the homeworld of the player does not have its population changed by this effect. It should be set to the max population allowed on the planet, after clamping, but it is unchanged, other than normal population growth each turn. Geoff the Medio 15:54, 23 May 2005 (EDT)

WithinStarlaneJumps between systems

Replace techs.xml with this:

<?xml version="1.0"?>
 <GG::XMLDoc>
 <Category>LEARNING_CATEGORY</Category>
  <Tech>
    <name>LRN_PHYS_BRAIN</name>
    <description>LRN_PHYS_BRAIN_DESC</description>
    <type>TT_THEORY</type>
    <category>LEARNING_CATEGORY</category>
    <research_cost>10</research_cost>
    <research_turns>1</research_turns>
    <effects>
      <EffectsGroup>
        <scope>
          <Condition::And>
            <Condition::Not>
              <Condition::WithinStarlaneJumps>
                <jumps>2</jumps>
                <condition><Condition::Self/></condition>
              </Condition::WithinStarlaneJumps>
            </Condition::Not>
            <Condition::Type>OBJ_SHIP</Condition::Type>
          </Condition::And>
        </scope>
        <activation>
          <Condition::Self/>
        </activation>
        <effects>
          <Effect::Destroy/>
        </effects>
      </EffectsGroup>
    </effects>
    <prerequisites></prerequisites>
    <unlocked_items></unlocked_items>
  </Tech>
</GG::XMLDoc>

Start a game, and move a fleet along a starlane away from your home planet that is longer than 1 turn's travel. End the turn. The fleet will be gone the next turn. (unless you game crashed due to other bugs).

The WithinStarlaneJumps condition is excluding objects that are within the indicated distance, but are not located at systems. In this case, fleets moving between systems, both of which are within the indicated number of jumps, are excluding, and thus re-included by the NOT condition.

This is fixed now. --Zach


System Ownership Retained After Planet Deletion

Replace techs.xml with this:

 <GG::XMLDoc>
 <Category>LEARNING_CATEGORY</Category>
  <Tech>
    <name>LRN_PHYS_BRAIN</name>
    <description>LRN_PHYS_BRAIN_DESC</description>
    <type>TT_THEORY</type>
    <category>LEARNING_CATEGORY</category>
    <research_cost>10</research_cost>
    <research_turns>1</research_turns>
    <effects>
      <EffectsGroup>
        <scope>
          <Condition::MeterValue>
            <meter>METER_RESEARCH</meter>
            <low>24</low>
            <high>999</high>
            <max_meter>0</max_meter>
          </Condition::MeterValue>
        </scope>
        <activation>
          <Condition::Self/>
        </activation>
        <effects>
          <Effect::Destroy/>
        </effects>
      </EffectsGroup>
    </effects>
    <prerequisites></prerequisites>
    <unlocked_items></unlocked_items>
  </Tech>
</GG::XMLDoc>

Start a game, set your planet's focus to research / research. End turn until the meter grows big enough and the planet is deleted by the effect. The system name is still coloured with your empire colour, and presumably you still "own" the system according to the game. If you have no colonized planets in a system, it should revert to unowned, as if your planet had starved and been lost.

Fixed. --Zach

Primary Focus Condition: Specialized includes Balanced

Replace techs.xml with this:

<?xml version="1.0"?>
 <GG::XMLDoc>
 <Category>LEARNING_CATEGORY</Category>
  <Tech>
    <name>LRN_PHYS_BRAIN</name>
    <description>LRN_PHYS_BRAIN_DESC</description>
    <type>TT_THEORY</type>
    <category>LEARNING_CATEGORY</category>
    <research_cost>10</research_cost>
    <research_turns>1</research_turns>
    <effects>
     <EffectsGroup>
       <scope>
         <Condition::FocusType>
           <primary>1</primary>
           <FocusType>FOCUS_RESEARCH</FocusType>
         </Condition::FocusType>
       </scope>
       <activation><Condition::Self/></activation>
       <effects>
         <Effect::SetPlanetType>PT_GAIA</Effect::SetPlanetType>
       </effects>
     </EffectsGroup>
    </effects>
    <prerequisites></prerequisites>
    <unlocked_items></unlocked_items>
  </Tech>
</GG::XMLDoc>

Start a game and set your planet's focus to Primary Balanced (and any Secondary setting). Research the tech.

The effect of the tech fires upon the planet with Primary Balanced focus (including all uninhabited planets). It also fires if the planet's focus is set to Primary Research.

The effect does not fire on Primary Farming or other non-Balanced and non-Research focus. The Secondary Focus setting does not matter.

This effect should fire only on planets with Primary Research focus. That is, the FocusType condition should not include Primary Balanced planets when the condition requesets Primary Research, Primary Farming, Primary Mining, Primary Industry or Primary Trade focus.

As well, the FocusType condition should not include uninhabited planets, regardless of the specified FocusType.

Also note that thet effect description text (appears below tech description on research screen) says the scope include primary balanced or primary research planets. This text should not be shown as is, but should be replaced with an optional effects desription text in the stringtable, perhaps as part of the tech description entry.

Fixed. --Zach

Secondary Focus Condition: Functions as Primary

Replace techs.xml with this:

<?xml version="1.0"?>
 <GG::XMLDoc>
 <Category>LEARNING_CATEGORY</Category>
  <Tech>
    <name>LRN_PHYS_BRAIN</name>
    <description>LRN_PHYS_BRAIN_DESC</description>
    <type>TT_THEORY</type>
    <category>LEARNING_CATEGORY</category>
    <research_cost>10</research_cost>
    <research_turns>1</research_turns>
    <effects>
     <EffectsGroup>
       <scope>
         <Condition::FocusType>
           <primary>0</primary>
           <FocusType>FOCUS_RESEARCH</FocusType>
         </Condition::FocusType>
       </scope>
       <activation><Condition::Self/></activation>
       <effects>
         <Effect::SetPlanetType>PT_GAIA</Effect::SetPlanetType>
       </effects>
     </EffectsGroup>
    </effects>
    <prerequisites></prerequisites>
    <unlocked_items></unlocked_items>
  </Tech>
</GG::XMLDoc>

Start a game and set your planet's focus to Primary Farming and Secondary Research. Research the tech, and end turn a few times to give the effect a chance to fire. It does not fire. Change the planet focus to Primary Research and Secondary Farming. End the turn. The effect fires, changing the planet's environment to Gaia.

The effect only fires on Primary Research focused worlds. The Secondary focus setting does not matter.

The effect should fire on Secondary Research focused worlds, and the Primary focus setting should not matter. That is, the FocusType condition should include Secondary Research focused planets, and not include other planets whose Secondary focus is not Research, when the specified focus is Secondary Research

Also note that thet effect description text (appears below tech description on research screen) says the scope include primary focus unknown or research. As above, this text should not be shown as is, and should be replaced with something from the stringtable.

Fixed. --Zach

Chance Condition

Replace techs.xml with the following:

<?xml version="1.0"?>
 <GG::XMLDoc>
 <Category>LEARNING_CATEGORY</Category>
  <Tech>
    <name>LRN_PHYS_BRAIN</name>
    <description>LRN_PHYS_BRAIN_DESC</description>
    <type>TT_THEORY</type>
    <category>LEARNING_CATEGORY</category>
    <research_cost>10</research_cost>
    <research_turns>1</research_turns>
    <effects>
     <EffectsGroup>
       <scope>
         <Condition::Chance>
          <chance>0.3</chance>
         </Condition::Chance>
       </scope>
       <activation><Condition::Self/></activation>
       <effects>
         <Effect::SetPlanetType>PT_GAIA</Effect::SetPlanetType>
       </effects>
     </EffectsGroup>
    </effects>
    <prerequisites></prerequisites>
    <unlocked_items></unlocked_items>
  </Tech>
</GG::XMLDoc>

Run the game, open up the research screen, and click on the tech. The game crashes.

The problem occurs when the Chance condition is used. That is, this part of the above tech:

<Condition::Chance>
  <chance>0.3</chance>
</Condition::Chance>

The error in the text window is:

1115148965 ERROR  : main() caught exception(boost::io::format_error): boost::bad
_format_string: format-string is ill-formed


Investigation / Workaround

The problem seems to be with the text in eng_stringtable.txt that is used as the format string for the description for the chance condition. The problematic strings are:

DESC_CHANCE_PERCENTAGE
 on a %1%% chance

DESC_CHANCE_PERCENTAGE_NOT
 on a (100 - %1%)% chance

The extra %'s for "percent" seem to be messing with boost's parser.

Fixed. For future reference, "%%" prints out a '%' character. --Zach

Destroy Effect On Ships Doesn't Remove Now-Empty Fleets

Replace techs.xml with the following:

<?xml version="1.0"?>
 <GG::XMLDoc>
 <Category>LEARNING_CATEGORY</Category>
  <Tech>
    <name>LRN_PHYS_BRAIN</name>
    <description>LRN_PHYS_BRAIN_DESC</description>
    <type>TT_THEORY</type>
    <category>LEARNING_CATEGORY</category>
    <research_cost>10</research_cost>
    <research_turns>1</research_turns>
    <effects>
     <EffectsGroup>
       <scope>
         <Condition::Type>OBJ_SHIP</Condition::Type>
       </scope>
       <activation><Condition::Self/></activation>
       <effects>
         <Effect::Destroy/>
       </effects>
     </EffectsGroup>
    </effects>
    <prerequisites></prerequisites>
    <unlocked_items></unlocked_items>
  </Tech>
</GG::XMLDoc>

Start the game, research the tech, end the turn a few times. Click on your fleet icon at the homeworld, or press the fleets button, F. The game crashes.

Fixed. --Zach

Crash: Not WithinStarlaneJumps Destroy

Put this as your techs.xml:

<?xml version="1.0"?>
 <GG::XMLDoc>
 <Category>LEARNING_CATEGORY</Category>
  <Tech>
    <name>LRN_PHYS_BRAIN</name>
    <description>LRN_PHYS_BRAIN_DESC</description>
    <type>TT_THEORY</type>
    <category>LEARNING_CATEGORY</category>
    <research_cost>10</research_cost>
    <research_turns>1</research_turns>
    <effects>
      <EffectsGroup>
        <scope>
          <Condition::Not>
            <Condition::WithinStarlaneJumps>
              <jumps>2</jumps>
              <condition><Condition::Self/></condition>
            </Condition::WithinStarlaneJumps>
          </Condition::Not>
        </scope>
        <activation>
          <Condition::Self/>
        </activation>
        <effects>
          <Effect::Destroy/>
        </effects>
      </EffectsGroup>
    </effects>
    <prerequisites></prerequisites>
    <unlocked_items></unlocked_items>
  </Tech>
</GG::XMLDoc>

Start a new game, research the tech, end your turn. The game thinks for a while, then crashes.

Fixed. --Zach

Working Effects and Conditions

The following effects and conditions seem to be working:

  • <Condition::And>
  • <Condition::StarType>
    • STAR_YELLOW
    • STAR_ORANGE
  • <Condition::Type>
    • OBJ_PLANET
    • OBJ_SHIP
  • <Condition::Self/>
    • Home planet of race that knows a tech
  • Destroy
    • Generally works, but has fundamental problems that intermittantly pop up
  • SetPlanetType
    • On habitable environments to other habitable environments (Not involving Gas Giant or Asteroids)
  • <Effect::SetMeter>
    • METER_POPULATION, max value, except for previously uninhabitable planets
  • <Condition::WithinDistance>
  • <Effect::SetEmpireStockpile>
    • ST_MINERAL