Endgame code

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
JamesG
Engineer
Engineer
Posts: 7
Joined: 22 Oct 2009 18:22

Endgame code

Post by JamesG »

Hi,

I'm trying to adjust NetworkCheckRestartMap() in network_server.cpp to end the server rather than restart the map, so that a simple shell script will run the server with a different configuration file each time. I just need a way to end the server nicely - exit(0) works, but doesn't shut down the server properly, and would leave an advertisement on the list server.

Thanks,

--James.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Endgame code

Post by Yexo »

See http://hg.openttd.org/openttd/trunk.hg/ ... .cpp#l1319. That's the code that handles the console command "exit". In short, just set _exit_game = true;
JamesG
Engineer
Engineer
Posts: 7
Joined: 22 Oct 2009 18:22

Re: Endgame code

Post by JamesG »

Thanks, will post back when I've written the new function
JamesG
Engineer
Engineer
Posts: 7
Joined: 22 Oct 2009 18:22

Re: Endgame code

Post by JamesG »

Just wrote the new function, but I had to #include openttd.h to get _exit_game. Also added a warning a year before the game ends.

Thanks,

--James.
petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: Endgame code

Post by petert »

JamesG wrote:Also added a warning a year before the game ends.
How does OpenTTD determine when the game (will) end?
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Endgame code

Post by Yexo »

petert wrote:
JamesG wrote:Also added a warning a year before the game ends.
How does OpenTTD determine when the game (will) end?
The setting network.restart_game_year
JamesG
Engineer
Engineer
Posts: 7
Joined: 22 Oct 2009 18:22

Re: Endgame code

Post by JamesG »

No; I created a new setting network.end_game_year, so the game will still restart if the restart year is the same or earlier.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 2 guests