Turn processing/stages

Programmers discuss here anything related to FreeOrion programming. Primarily for the developers to discuss.

Moderator: Committer

Post Reply
Message
Author
User avatar
Oberlus
Cosmic Dragon
Posts: 5704
Joined: Mon Apr 10, 2017 4:25 pm

Turn processing/stages

#1 Post by Oberlus »

Where can I find the piece/s of code or documentation to learn about what is processed when on each turn?
I need answers to stuff like "do all effects apply before or after invasion orders?", "if I order an invasion before pressing 'Turn 100', the invasion happens on turn 100 or turn 101 (LastTurnAttackedByShip gets the value 100 or 101)?", etc.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13586
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Turn processing/stages

#2 Post by Geoff the Medio »

Mostly look at ServerApp::PreCombatProcessTurns and ServerApp::PostCombatProcessTurns:
https://github.com/freeorion/freeorion/ ... .cpp#L3183
https://github.com/freeorion/freeorion/ ... .cpp#L3405

also incrementing the turn number:
https://github.com/freeorion/freeorion/ ... .cpp#L3552

User avatar
The Silent One
Graphics
Posts: 1129
Joined: Tue Jul 01, 2003 8:27 pm

Re: Turn processing/stages

#3 Post by The Silent One »

Oberlus wrote: Sun Oct 18, 2020 9:48 am Where can I find the piece/s of code or documentation to learn about what is processed when on each turn?
I need answers to stuff like "do all effects apply before or after invasion orders?", "if I order an invasion before pressing 'Turn 100', the invasion happens on turn 100 or turn 101 (LastTurnAttackedByShip gets the value 100 or 101)?", etc.
There is a tooltip on the turn button that gives you a rough overview what's happening when, too.
If I provided any images, code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0.

User avatar
Oberlus
Cosmic Dragon
Posts: 5704
Joined: Mon Apr 10, 2017 4:25 pm

Re: Turn processing/stages

#4 Post by Oberlus »

Thanks.

So we have

Order execution
  1. Colonization
  2. Invasion
  3. Bombardment
  4. Gifting
  5. Scrapping
  6. Fleet movement
Combat Resolution

Production, Research and Growth
  1. Effect execution
  2. Production of ships and buildings
  3. Unlocking of new technologies
  4. Population growth <- Isn't Population growth managed by the effects?
  5. Supply update

Why not Effect execution after production of ships and buildings? Maybe so that available PP/RP are the ones reported on previous turn?

Ophiuchus
Programmer
Posts: 3427
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Re: Turn processing/stages

#5 Post by Ophiuchus »

Oberlus wrote: Sun Oct 18, 2020 2:47 pm Why not Effect execution after production of ships and buildings? Maybe so that available PP/RP are the ones reported on previous turn?
There is effect execution without effect accounting after processing of queues (which includes production). See https://github.com/freeorion/freeorion/ ... .cpp#L3499

I am just not sure why we have effect execution before processing of queues. Having projected changes to resources and supply actually happen before processing of queue is counterintuitive to me.
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13586
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Turn processing/stages

#6 Post by Geoff the Medio »

Ophiuchus wrote: Sun Oct 18, 2020 3:00 pmI am just not sure why we have effect execution before processing of queues. Having projected changes to resources and supply actually happen before processing of queue is counterintuitive to me.
This way, players can issue an order during turns and the resource output / progress on queues will respond to those orders immediately, rather than depending only on orders from the previous turn.

Post Reply