Compiling with MinGW, help needed!

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
User avatar
escopena
Engineer
Engineer
Posts: 28
Joined: 22 Aug 2006 10:03
Location: Finland

Compiling with MinGW, help needed!

Post by escopena »

Hi,

I have installed MinGW couple of times. After first time svn didn't work propely. So I installed it again following strictly LKRaiders advices. Now everything is working but I wonder why it now compile every single file if I have modified only one. After first installation it only compiled those files I had modified. Now it takes long time to test simply things. Is there some attribute in makefile.config or somewhere else to control this issue?


Btw, what does this mean?

Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" ' unrecognized

Thanks!
Yeah!
User avatar
glx
OpenTTD Developer
OpenTTD Developer
Posts: 623
Joined: 02 Dec 2005 15:43
Location: Drancy(93) - France
Contact:

Post by glx »

If you have modified a header (like openttd.h), all files that includes it are recompiled and it's normal.
Frostregen
Transport Coordinator
Transport Coordinator
Posts: 340
Joined: 06 Feb 2006 23:58

Re: Compiling with MinGW, help needed!

Post by Frostregen »

escopena wrote: Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" ' unrecognized
This is no problem, but a bit annyoing.
I want to get rid of this too ;)

It has something to do with libpng or zlib or both....

Help needed =)
User avatar
escopena
Engineer
Engineer
Posts: 28
Joined: 22 Aug 2006 10:03
Location: Finland

Post by escopena »

glx wrote:If you have modified a header (like openttd.h), all files that includes it are recompiled and it's normal.
I modified only player.c
Yeah!
MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

Post by MeusH »

Don't make clean. At least it won't re-compile over and over again all the files
User avatar
escopena
Engineer
Engineer
Posts: 28
Joined: 22 Aug 2006 10:03
Location: Finland

Post by escopena »

MeusH wrote:Don't make clean. At least it won't re-compile over and over again all the files
What does it mean to leave it unclean? Does it leave some temp files somewhere?
Yeah!
MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

Post by MeusH »

yeah, .o files are everywhere

make clean removes them.
User avatar
escopena
Engineer
Engineer
Posts: 28
Joined: 22 Aug 2006 10:03
Location: Finland

Post by escopena »

Hi,

I have now been messing with source code couple times. There is screenshot as attachment of finance table with my experimental Tax System. It calculates real income and takes 25% tax of it. Tax is take from player at 1st day of next year.

This is my first C-programing project so there is many quesitions in my mind.

How does int32 and int64 'types'(or what ever their are) work? Can they be mixed or how to get int64 value form int32? Is it posible to get int32 value from int64? How to handle overflow?

Strings are also problematic for me. How does StringID work(what is the idea behind)? SetDParam64() SetDParam() etc. are also mysterious. How to set up two different strings for example for ShowErrorMessage(). Is it possible, following does not work:

Code: Select all

         money = 5000;
         cur_tax_sum = 3000;

	str_money = STR_7028;
	SetDParam64(0, money);

	str_tax = STR_7028;
	SetDParam64(0, cur_tax_sum);

	ShowErrorMessage(str_money, str_tax, 0, 0);

Is there better way to print out some debug info than use ShowErrorMessage()

I have many other questions also but I'll continue later... Thanks for help!
Attachments
Tax System
Tax System
tax-system-001.png (26.83 KiB) Viewed 3071 times
Yeah!
gigajum
Route Supervisor
Route Supervisor
Posts: 511
Joined: 08 Mar 2006 08:33
Location: Germany

Post by gigajum »

escopena wrote:Hi,

I have now been messing with source code couple times. There is screenshot as attachment of finance table with my experimental Tax System. It calculates real income and takes 25% tax of it. Tax is take from player at 1st day of next year.

This is my first C-programing project so there is many quesitions in my mind.

How does int32 and int64 'types'(or what ever their are) work? Can they be mixed or how to get int64 value form int32? Is it posible to get int32 value from int64? How to handle overflow?

Strings are also problematic for me. How does StringID work(what is the idea behind)? SetDParam64() SetDParam() etc. are also mysterious. How to set up two different strings for example for ShowErrorMessage(). Is it possible, following does not work:

Code: Select all

         money = 5000;
         cur_tax_sum = 3000;

	str_money = STR_7028;
	SetDParam64(0, money);

	str_tax = STR_7028;
	SetDParam64(0, cur_tax_sum);

	ShowErrorMessage(str_money, str_tax, 0, 0);

Is there better way to print out some debug info than use ShowErrorMessage()

I have many other questions also but I'll continue later... Thanks for help!
The string system is bit hard to understand at the begining. But if you know how to use it you will see that it works good. You can use SetDParam with stringsID, too.
The most work with strings i did were in the additional orders patch. A few lines: (in hope they explain themself)

Code: Select all

Index: lang/english.txt
===================================================================
STR_NEW_GO_TO                                                   :Go to {STATION} ({STRING})
STR_NEW_GO_NON_STOP_TO                                          :Go non-stop to {STATION} ({STRING})
STR_LOADING_BTN                                                 :{BLACK}Loading
STR_ORDER_TRANSFER                                              :Transfer and take cargo
STR_ORDER_LOAD                                                  :{STRING} Load{STRING}{STRING}
STR_ORDER_LOAD_ONLY                                             :{STRING} Load only{STRING}{STRING}
STR_ORDER_TRANSFER_LOAD                                         :Transfer and wait for {STRING} load{STRING}{STRING}
STR_ORDER_TRANSFER_LOAD_ONLY                                    :Transfer and wait for exact {STRING} load{STRING}{STRING}
STR_ORDER_UNLOAD                                                :{STRING} Unload
STR_ORDER_UNLOAD_ONLY                                           :{STRING} Unload only
STR_ORDER_TRANSFER_UNLOAD                                       :Transfer and leave empty
STR_ORDER_PRIORITY												: (priority)
STR_ORDER_PRIORITY_BTN                                          :{BLACK}Priority
STR_ORDER_LOAD_EXACT                                            :{BLACK}Load Exact
STR_ORDER_LOAD_EXACT_HINT                                       :{BLACK}load not more then set
STR_ORDER_PRIORITY_HINT                                         :{BLACK}train has priority loading
STR_ORDER_MISC_BTN                                              :{BLACK}Misc.
STR_ORDER_PERCENT_BTN                                           :{BLACK}% loading
STR_ORDER_PERCENT_HINT                                          :{BLACK}load/unload 10 percent more or less
STR_ORDER_LOAD_PER_TRAIN                                        : of train
STR_ORDER_LOAD_PER_CARGO                                        : of any cargo
STR_ORDER_LOAD_PER_BTN                                          :{BLACK}Load base
STR_ORDER_LOAD_PER_HINT                                         :{BLACK}Train will be loaded based on any cargo or train

##### Range for Percentile loads #####
STR_ORDER_10                                                    :10%
STR_ORDER_20                                                    :20%
STR_ORDER_30                                                    :30%
STR_ORDER_40                                                    :40%
STR_ORDER_50                                                    :half
STR_ORDER_60                                                    :60%
STR_ORDER_70                                                    :70%
STR_ORDER_80                                                    :80%
STR_ORDER_90                                                    :90%
STR_ORDER_100                                                   :full
##### End of range for Percentile loads #####

Index: order_gui.c
===================================================================
					if(HASBIT(order->flags, OFB_NON_STOP))
					    SetDParam(1, STR_880C_GO_NON_STOP_TO);
					else
						SetDParam(1, STR_8806_GO_TO);
					// Use the originals if only Non stop is set (or not)
					if (order->flags == OF_NON_STOP || order->flags == 0) {
					    SetDParam(2, order->station);
					} else {
					    SetDParam(1, STR_NEW_GO_TO);
						
					    // Non-Stop
					    if(HASBIT(order->flags, OFB_NON_STOP))
						SetDParam(1, STR_NEW_GO_NON_STOP_TO);
	
					    SetDParam(2, order->station);
						
						// Transfer
						if(HASBIT(order->flags, OFB_TRANSFER))
							SetDParam(3, STR_ORDER_TRANSFER);

					    // Load
					    if(HASBIT(order->flags, OFB_FULL_LOAD))
							SetDParam(3, STR_ORDER_LOAD + (HASBIT(order->flags, OFB_EXACT_LOAD)?1:0)+ (HASBIT(order->flags, OFB_TRANSFER)?2:0));
	
					    // Unload
					    else if(HASBIT(order->flags, OFB_UNLOAD))
							SetDParam(3, STR_ORDER_UNLOAD + (HASBIT(order->flags, OFB_EXACT_LOAD)?1:0) + (HASBIT(order->flags, OFB_TRANSFER)?2:0));
	
					    // The percentile of load
					    if(HASBIT(order->flags, OFB_UNLOAD) || HASBIT(order->flags, OFB_FULL_LOAD)) {
							if(order->percentilefill)
								SetDParam(4, STR_ORDER_10 + (order->percentilefill / 10) -1);
							else
								SetDParam(4, STR_ORDER_10 + 9);	// 100% load
					    }
						
						if(HASBIT(order->flags, OFB_CARGO_LOAD)){
							SetDParam(5, STR_ORDER_LOAD_PER_TRAIN);
						} else {
							SetDParam(5, STR_ORDER_LOAD_PER_CARGO);
						}
						if(HASBIT(order->flags, OFB_PRIORITY)){
							SetDParam(6, STR_ORDER_PRIORITY);
						} else {
							SetDParam(6, STR_EMPTY);
						}
					}
In the wiki there is a page with all special strings (like {STRING}) that you can use.


For better debug:

Code: Select all

debug("text usage like printf and co %d", value);
then you get debug messages on your console, if you made a debug build
Last edited by gigajum on 03 Sep 2006 12:19, edited 1 time in total.
User avatar
Maedhros
OpenTTD Developer
OpenTTD Developer
Posts: 603
Joined: 30 Mar 2006 18:24
Location: Durham, UK

Post by Maedhros »

escopena wrote:How does int32 and int64 'types'(or what ever their are) work? Can they be mixed or how to get int64 value form int32? Is it posible to get int32 value from int64? How to handle overflow?
They just refer to the size of the variable - int32 is a (signed, I think) 32-bit integer, and int64 has 64 bits. You can't get a 64-bit value from a variable that only has 32 bits, but if you mean you want to store the value from an int32 in an int64, you can "cast" the value:

Code: Select all

int32 foo = 14;
int64 bar = (int64)foo;
You have to make sure the type you're casting to is big enough to hold the value, or else you'll lose the remaining information.

The only thing you can do about overflows is make sure either that the value can never get that large, or check the new value is less than the maximum for that type (there may be enums for that in a header file somewhere).
No-one's more important than the earthworm.
User avatar
escopena
Engineer
Engineer
Posts: 28
Joined: 22 Aug 2006 10:03
Location: Finland

Post by escopena »

We played first network game with my Tax Patch. It worked fine. But there was some problem when clients were connecting to my server. They got error message like:

Code: Select all

Microsoft assertion failed.
network.c
line 1198
We are using build r6239M. Anybody else got similar problems?

Next question is:

How to define new fields to save file? I need to save and load an array.
Yeah!
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 25 guests