Page 1 of 1

Server - Main Game Loop

Posted: 07 Dec 2006 17:58
by aarona
When the game is being run, the server acts like a black box and just does stuff while looking really dull.

Code: Select all

while (game == active)
{
	tickframe()			'FPS nominal?
	if newday then tickday()	'day = ? ticks
	if newmonth then tickmonth()	'month = 28/9/ 30/1 days
	if newyear the tickyear()	'year = startdate + yearsplayed
}

if game != active
	tell everyone the game has finished
	clean up
	end

tickframe()
	update all vehicles
		broken down?
			update counter
			counter finished?
				make no longer broken down
		at station?
			just arrived?
				add $ if del. complete
			load/unload

		otherwise - move
			

tickday()
	will vehicle breakdown today? (should breakdown probability be in days?)
		make broken down, reset counter
	stock market stuff
	update daily town stuff

tickmonth()
	update industry
	update monthly counters
	update economic indicators
	interest repayments, etc
	update monthly town stuff
	
tickyear()
	update year counters
	update all yearly depedent parameters
I want to leave discussion about server <-> client interaction until later...

Have I missed anything? (I know I have...)