[Freeciv-Dev] Re: (PR#725) Order of end/new-turn activities
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=725 >
ue80@xxxxxxxxxxxxxxxxxxxxx wrote:
> I've tried to search the activities at the end/begin of a turn.
>
> I have no idea how to visualize the problem.
I went through and made an exhaustive list of such actions. It's attached.
I also have no good way to visiualize the problem. Even breaking it
down into broad categories may be impossible because elements in the
same category may have conflicting dependencies.
I believe I made a similar but incomplete list before. However I
intentionally didn't look at it yet so that they can now be compared.
jason
begin turn (this happens before each turn):
- Reset fog of war if game.fog_of_war is changed.
- For each player:
- Do nothing [1].
- Reset all sorts of AI/advisor data.
- For each player:
- For each city:
- "Refresh" the city [2].
- Send updated info about the city to the owner.
- For each player:
- If they are a non-barbarian AI player
- Do diplomacy (threats, war, etc).
- Reshuffle players.
- Do AI beginning-of-turn actions (complicated).
- Tell clients the turn has started.
- "Thaw" clients.
- Autosave.
Then the turn happens.
end turn (this happens after each turn):
- Tell the clients the turn is over.
- "Freeze" clients.
- Summon barbarians.
- Move autosettlers (very complicated).
- Do autoattack:
- For each shuffled player:
- For each city:
- For each unit in the city:
- Auto-attack, if applicable.
- For each unit the player owns:
- If the unit may have auto-attacked the previous turn, return it
to the city.
- Freeze sending of cities.
- For all ai players:
- Do AI end-of-turn activities (complicated).
- For all shuffled players:
- Give techs for great library.
- Decrement anarchy turn count.
- "restore" units:
- Leonardo's upgrades
- For all units the player owns:
- Gain/lose HP for rest, united nations, helicoptor. Activate
sentried units that lost HP.
- Kill units with no HP.
- Kill or veteran triremes far from the coast.
- If the unit is an air unit:
- "Return" planes that are out of fuel to the nearest landing point.
- Decrease plane fuel
- Refuel if the plane is landed
- For all units the player owns:
- Crash the plane if it's out of fuel.
- "Update" cities:
- For each city the player owns:
- "Refresh" the city [2].
- Calculate production:
- Account for unit shield upkeep; kill units if necessary.
- Increase shield stock from shield surplus.
- Reset the last-turns-shields values (the values used when
changing production - there are 6 such values [3]).
- If the city is building a building:
- Give money for capitalization.
- Upgrade building production.
- Fail if the building isn't buildable (obsolete).
- Build the building if there's enough shield stock:
- Remove duplicate palaces.
- Add space parts, if applicable.
- And add the improvement to the city.
- Decrease shield stock.
- Update "before change shields" and "turn last built".
- Notify for built wonders.
- Notify for the built building.
- Give techs for darwins'.
- Notify for newly-started spaceships.
- Send new spaceship info to clients.
- "Refresh" city [2].
- Choose new build target from worklist or advisor.
- If the city is building a unit:
- Upgrade unit production.
- Fail if the unit is unbuildable/obsolete.
- If there's enough sheild stock to complete the production:
- Disband the city if applicable.
- Fail if we don't want to disband the city.
- Update "turn last built".
- Create the new unit.
- Reduce population if unit has pop_cost.
- Update shield stock and "before-change shields".
- Notify player of built unit.
- Pick new production from worklist or advisor.
- If the city has died, skip the rest of the updates.
- Update celebration:
- If the city is celebrating [4]:
- Increase rapture (+1).
- Notify player if city just started rapture (rapture == 1).
- If city is not celebrating:
- Notify player if city just ended rapture (rapture != 0).
- Reset rapture (to 0).
- Update was_happy (which is used to determine whether the
city celebrates next turn).
- Update population:
- Increase food stock from food surplus (may be negative).
- Increase city size for full granary or rapture.
- If food stock is negative:
- Kill a single unit if possible.
- Otherwise famine: reduce city size, reset granary. [5]
- If the city has died, skip the rest of the updates.
- Reset is_updated, did_sell, did_buy, airlift.
- Add bulbs from research in this city:
- Add bulbs to total (including teammates).
- Complete research, if possible.
- Add tax to treasury.
- Pay for units supported by this city.
- Pay for buildings in this city.
- If city is unhappy, put it into anarchy and notify player.
- If city isn't unhappy, end anarchy and notify player.
- Add map pollution.
- Send city info to everyone.
- If anarchy > 2 and in democracy, drop civ into anarchy.
- Reset research "changed from" value.
- Kill any dead or dying players.
- "Thaw" cities.
- For all players:
- Send owner info about all their cities.
- Reset some AI data.
- Update global warming from map pollution.
- Update nuclear winter from map fallout.
- Update "diplomatics":
- For all players
- For all other players
- Decrement ceasefire, contact, reason_to_cancel.
- Break ceasefire or notify of impending expiration.
- update player reputation [6].
- Reveal map for apollo.
- Make contact for marco pollo.
- Update civ scores, and make history report every 20 turns.
- Notify players of the turn (complicated).
- Advance the year and increment the turn #.
- For each shuffled player:
- For each unit owned by that player:
- Update the unit's activity. (This is complicated and will have
it's own dependencies. But for now I skip it.)
- Update timeout.
- Check for spaceship arrivals.
- Send out player, game, and year info.
- Send new info to the metaserver.
[1] An empty function call inside another empty function call. Should be
removed.
[2] The city refresh is a complicated update. But it doesn't actually do
anything, just updates some possibly-stale values.
[3] This is done in 3 different function calls. Should be merged into a single
function.
[4] A city celebrates if was_happy is set and it's large enough.
[5] We only kill off one unit _or_ have famine. With a large negative food
this could be a bug. Say you have 0 food in the store, with a surplus of -3
and supporting a settlers (upkeep 2). Now you'll kill the settlers, reset the
surplus to 0, and there will be no famine. So basically you get a free food.
[6] This is almost certainly a bug, since it means each player's reputation is
reset many times per turn.
|
|