Seasons (changing snowline, trees, fields)

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

User avatar
prissi
Chief Executive
Chief Executive
Posts: 647
Joined: 15 Nov 2004 19:46
Location: Berlin, Germany
Contact:

Seasons (changing snowline, trees, fields)

Post by prissi »

If you want to have a day and night cycle, here is a diff you have to apply to gfx.c. Know problem: Intro seems to use DOS colors, game is Windows, so the first night colors can be off. Not configurable, since I really did not want to dig into the gui.
Attachments
daynight.diff
Apply to 0.4.0.1
(1.3 KiB) Downloaded 779 times
Last edited by prissi on 28 Sep 2006 08:18, edited 2 times in total.
Hazelrah
Traffic Manager
Traffic Manager
Posts: 196
Joined: 13 Apr 2005 05:41

Post by Hazelrah »

prissi,

I tried applying your patch using TortoiseSVN for windows, and it gave me the following error:

Code: Select all

The line "Index:" was not found!
Either this is not a diff file or the file is empty.
I opened up the diff file and indeed it is not the same as any other diff I've seen for OTTD. You said I should apply it directly to the file, but TortoiseSVN does not allow you to do this.

I'd like to check it out, so please could you try making the diff file again!

Thanks!

-Hazelrah
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

prissi: Please use diff -u. Just diff (or diff -e) creates files in a nearly useless format. Also, please make sure you produce a forward diff. I had to reverse that patch in order to successfully apply it.

Hazelrah: The patch(1) utility (available on Cygwin and all *nix distros) can use that diff file, with a little help.

Here's a unified diff (-u, for "useful"), but I'd like to know what line 1665

Code: Select all

memcmp(old_val, _cur_palette + 217*3, c*3);
is supposed to do. That memcmp *was* controlling an if statement, but you pulled controlled block, without pulling the controlling statement
Attachments
daynight.patch
(1.95 KiB) Downloaded 391 times
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
prissi
Chief Executive
Chief Executive
Posts: 647
Joined: 15 Nov 2004 19:46
Location: Berlin, Germany
Contact:

Post by prissi »

Ok, here i a diff -u which also corrected the initial color problem. I am not quite sure what you mean by forward, but I swapped both input files.

The if(memcpy()) was always executed, since c*3!=0. The settings are now made in the upper block, where decision about day/night is made.

At a more close analysis the memcpy old_val is useless, since old_val is a write only variable.
Attachments
daynight.diff
hopefully now in the desired format
(2.18 KiB) Downloaded 340 times
User avatar
lucaspiller
Tycoon
Tycoon
Posts: 1228
Joined: 18 Apr 2004 20:27

Post by lucaspiller »

How often is the day / night loop supposed to occur? I have been running it for a few months and as of yet nothing has happened. Also, I am sure the water wasn't purple before......
No longer active here, but you can still reach me via email: luca[at]stackednotion[dot]com
User avatar
GoneWacko
Tycoon
Tycoon
Posts: 8680
Joined: 10 Jul 2002 15:08
Location: Enschede, The Netherlands
Contact:

Post by GoneWacko »

Maybe it's not water but lemonade :O
GoneWacko. Making [url=irc://irc.oftc.net/tycoon]#tycoon[/url] sexy and exciting since 1784.
User avatar
lucaspiller
Tycoon
Tycoon
Posts: 1228
Joined: 18 Apr 2004 20:27

Post by lucaspiller »

I still haven't seen purple / pink lemonade before though, must be cherryade. :P
No longer active here, but you can still reach me via email: luca[at]stackednotion[dot]com
Nanaki13
Traffic Manager
Traffic Manager
Posts: 151
Joined: 08 Jan 2005 16:08

Post by Nanaki13 »

Patched, compiled, 3 years passed, nothing.
Hazelrah
Traffic Manager
Traffic Manager
Posts: 196
Joined: 13 Apr 2005 05:41

Post by Hazelrah »

prissi,

Sorry, but it still doesn't have the Index: filename.c that TortoiseSVN needs. Maybe because your doing the diff on only one file instead of the entire set of code. I'm not sure. DaleStan, any more hints? I used your diff file with no problems.

Also, I'm compiling with VC++ 6.0 which does not allow you to declare variables except for at the very top of the scope. This means that

Code: Select all

	YearMonthDay YMD;	
	ConvertDayToYMD(&YMD, _date);
	uint8 new_dark_state = (_game_mode != GM_MENU) ? dark_state[YMD.day-1] : 0;
results in a compiler error because your calling the function ConvertDayToYMD before declaring new_dark_state. You should change the code to read like this:

Code: Select all

	uint8 new_dark_state
	YearMonthDay YMD;	
	ConvertDayToYMD(&YMD, _date);
	new_dark_state = (_game_mode != GM_MENU) ? dark_state[YMD.day-1] : 0;
I tested the program with that small change, and it works fine for me now. Maybe the problems others are having have something to do with that?

For everyone's information, the cycle goes once a month

On the 24th, start getting dark
On the 26th, compleatly dark
On the 6th, start getting light
On the 8th, back to normal daylight

Since the game starts on the 1st, this means that a new game will be in the night time cycle.

-Hazelrah
Nanaki13
Traffic Manager
Traffic Manager
Posts: 151
Joined: 08 Jan 2005 16:08

Post by Nanaki13 »

can anybody post a build? it just doesn't work for me.
Hazelrah
Traffic Manager
Traffic Manager
Posts: 196
Joined: 13 Apr 2005 05:41

Post by Hazelrah »

Alright Nanaki, here you go.

Just to warn you though, this is not a clean build. It's got a few other things like PBS (out of date), subsidiaries, remove signal patch, and at least one more, I forget right now.
Attachments
HazelrahsBuild001.zip
Day and Night implemented
(973 KiB) Downloaded 531 times
User avatar
GoneWacko
Tycoon
Tycoon
Posts: 8680
Joined: 10 Jul 2002 15:08
Location: Enschede, The Netherlands
Contact:

Post by GoneWacko »

Hazelrah wrote:Also, I'm compiling with VC++ 6.0 which does not allow you to declare variables except for at the very top of the scope.
If I remember correctly it's also against the coding rules/standards, unless they've changed this bit recently.
GoneWacko. Making [url=irc://irc.oftc.net/tycoon]#tycoon[/url] sexy and exciting since 1784.
Hazelrah
Traffic Manager
Traffic Manager
Posts: 196
Joined: 13 Apr 2005 05:41

Post by Hazelrah »

You do remember correctly. It's the third blue dot down.

http://wiki.openttd.com/index.php/Coding_guidelines

-Hazelrah
User avatar
prissi
Chief Executive
Chief Executive
Posts: 647
Joined: 15 Nov 2004 19:46
Location: Berlin, Germany
Contact:

Post by prissi »

Oops, thank you. Apparently I did too many C99 recently. Actually, we could also save some time, if one only asks for the day if needed.

The darkening should occur from 1-6th day and then again near the end of the month.

And I am not sure, what SVN wants. The only thing I can do is diff -u x y. Naturally, these files have different names. Does SVN wants the same name?

(On Windows 98 svn can commit and download, but merge, patch etc. just crashes the computer or does nothing.)
Attachments
daynight.diff
Declaration fixed
(2.39 KiB) Downloaded 321 times
User avatar
Dextro
Chief Executive
Chief Executive
Posts: 701
Joined: 12 Jan 2005 21:56
Location: Lisboa, Portugal
Contact:

Post by Dextro »

just tried this out (using Hazelrah build) and it looks cute. The water is a bit glowy in the night so it's either full moon or radioactive waste LOOOOL :lol:

Another thig is the fact that the menus are also dark during the night what makes playing a bit hard :?

But I can see myself playing with this (as long as I could turn it of in the middle of the game), and someway to add small lightspots would be cool LOL :lol:
Uncle Dex Says: Follow the KISS Principle!
User avatar
GoneWacko
Tycoon
Tycoon
Posts: 8680
Joined: 10 Jul 2002 15:08
Location: Enschede, The Netherlands
Contact:

Re: Day & Night cycle

Post by GoneWacko »

prissi wrote:Not configurable, since I really did not want to dig into the gui.
Doing the GUI is my favorite part ^^
I love doing GUI stuff in OpenTTD. And from what I've seen on the chat channel I am one of the only ones =/
GoneWacko. Making [url=irc://irc.oftc.net/tycoon]#tycoon[/url] sexy and exciting since 1784.
Nanaki13
Traffic Manager
Traffic Manager
Posts: 151
Joined: 08 Jan 2005 16:08

Post by Nanaki13 »

Thanks for the build Hazelrah.

I had problems with it anyway.
I had to delete the config file for it to work.
I found out that the options full animation and full detail influence the night/day cycle.
If you turn them off in the middle of the night it will be night forever... or until game restart i think.
If they're off when you start the game (exe), there will be no cycle.

And my own build doesn't work anyway... dunno why.
And yeah, the dark menus are a bit hard to see.
User avatar
Born Acorn
Tycoon
Tycoon
Posts: 7588
Joined: 10 Dec 2002 20:36
Skype: bornacorn
Location: Wrexham, Wales
Contact:

Post by Born Acorn »

prssi : Great work. It works like a charm, but I have a few tiffs with it:

1. Night and Day should last a LOT longer, or be a configurable thing

2. It shouldn't affect the GUI.

3. The water colour at night is a bit light.
Image
User avatar
Villem
Tycoon
Tycoon
Posts: 3310
Joined: 28 Aug 2003 09:38

Post by Villem »

Can anyone post a screenshot ,please? :D
User avatar
prissi
Chief Executive
Chief Executive
Posts: 647
Joined: 15 Nov 2004 19:46
Location: Berlin, Germany
Contact:

Post by prissi »

Darker water: There you go.

The lenght of the night in in the array dark_state[]. Maybe this should be read from the openttd.cfg.

GUI: Please ask an OTTD guru. Might be impossible due to the 256 color limit.

And please, I mainly do other things than programming OTTD. I just did this hack to prove it is very easy to make some day/night. This is no way complete. At least, one can indeed switch this on ore off with full animation.

I feel, that for a real guru, winter and summer changes would be also not much harder, since all sprites exists already. Just the tree has to be picked for season, same for ground tile. (Would make month a global though.)
Attachments
daynight.diff
Darker Water
(3.31 KiB) Downloaded 337 times
Night
Night
night.png (89.5 KiB) Viewed 15639 times
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 4 guests