Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Sat Mar 25, 2017 11:36 pm

All times are UTC




Post new topic  Reply to topic  [ 54 posts ]  Go to page Previous 1 2 3
Author Message
PostPosted: Fri May 15, 2009 7:31 am 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Tue Apr 25, 2006 10:22 am
Posts: 261
Location: Bucharest
it`s time for me to learn some c++. right now I don`t know nothing about coding. I don`t even know what program I must use to create a program/patch etc, so can you tell me what program I must use to begin? thank you

I have a book, something like C++ for dummies :P

_________________
ImageImage


Top
   
PostPosted: Fri May 15, 2009 12:33 pm 
Offline
Tycoon
Tycoon

Joined: Sun Apr 08, 2007 4:07 am
Posts: 1884
What OS are you running?

_________________
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage


Top
   
PostPosted: Fri May 15, 2009 12:39 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Wed Nov 07, 2007 10:44 pm
Posts: 9006
Location: Sol d
Whatever, you should definitely read that page which answers those questions http://wiki.openttd.org/Development

_________________
Image
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML


Top
   
PostPosted: Fri May 15, 2009 1:18 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Tue Apr 25, 2006 10:22 am
Posts: 261
Location: Bucharest
@ Roujin : Windows Xp SP3

@planetmaker: yes, I know that page. Right now i don`t want to know from the start how to make a patch, right now I need to know the name of the program(s) where I will put those lines. You can call me idiot, stupid or whatever, I just don`t know even that simple thing for you, but I want to learn, ok? All I need right is just a straight answer and that`s the name of the program.. and maybe an informative link. If you can help me with that please leave an answer.

thank you.

_________________
ImageImage


Top
   
PostPosted: Fri May 15, 2009 1:42 pm 
Offline
Transport Coordinator
Transport Coordinator

Joined: Sun Jan 27, 2008 1:02 pm
Posts: 298
ColdIce wrote:
... and maybe an informative link...

http://wiki.openttd.org/Microsoft_Visua ... s_Editions

_________________
Create your own NewGRF? Check out this tutorial!


Top
   
PostPosted: Sun May 17, 2009 11:03 am 
Offline
Tycoon
Tycoon

Joined: Sun Apr 08, 2007 4:07 am
Posts: 1884
Yup, that's what I would also recommend if you're on windows.

here's the corresponding wiki page: http://wiki.openttd.org/Microsoft_Visua ... s_Editions

_________________
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage


Top
   
PostPosted: Sat Sep 05, 2009 10:51 am 
Offline
Director
Director
User avatar

Joined: Mon Jan 14, 2008 3:51 pm
Posts: 633
Location: PL
I wrote some time ago a regular expression to find some common coding style mistakes in MSVC using search tool. Probably someone will find it useful (MS syntax):

(:b$)|(^\t* [^*])|([^\t]\t)|(^:b*(([^/*:b]|(/[^/*]))([^/]|(/[^/*]))* )|()((if)|(while)|(for)|(switch))(([^{]\n:b*\{)|(\()))|(XXX)|(^\t*//)|(^\t*[^#\t].*/\*)

With this expression you can find:
- whitespace at the end of line
- tabs that are not at the beginning of line
- spaces before first non-whitespace character in the line, except one space before asterisk "*" (multiline comments)
- some mistakes in comments (I can't remember exactly)
- left brace "{" in wrong place after if/while/for/switch directive
- newline after if/while/for/switch directive without left brace "{" after
- no space after if/while/for/switch keyword
(inspired by Alberths expression):
- "XXX" string
- c comment "/*" after line with text, but not including preprocessor directives (hash "#" at the beginning)
- cpp comment "//" without text before

... and probably something more that I can't remember, I won't analyse this creepy expression till it works well.

If you have any concrete, real suggestions to improve expression - write them here.

_________________
:] don't worry, be happy and checkout my patches


Last edited by adf88 on Fri Sep 25, 2009 7:38 am, edited 10 times in total.

Top
   
PostPosted: Sat Sep 05, 2009 11:22 am 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Sun Sep 09, 2007 5:03 am
Posts: 4303
Location: home
I have been using a python program for some time.
Usage:
Code:
python chk_patch.py <name of patch-file>
Your checks are somewhat different, maybe they can be merged in some way. (Feel free to do so and post an update.)


Attachments:
File comment: Python file to check patch files for coding mistakes (drop the .txt extension).
chk_patch.py.txt [1.47 KiB]
Downloaded 211 times
Top
   
PostPosted: Sat Sep 05, 2009 1:17 pm 
Offline
TTDPatch Developer
TTDPatch Developer

Joined: Wed Feb 18, 2004 3:06 am
Posts: 10285
adf88 wrote:
(:b$)|(^\t* [^*])|([^\t]\t)|(^:b*(([^/*:b]|(/[^/*]))([^/]|(/[^/*]))* )|()((if)|(while)|(for)|(switch))(([^{]\n:b*\{)|(\()))
Are you quite sure that's not line noise? :p

(Sorry. This isn't a suggestion. I'm just impressed.)

_________________
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


Top
   
PostPosted: Sat Sep 05, 2009 1:23 pm 
Offline
Director
Director
User avatar

Joined: Mon Jan 14, 2008 3:51 pm
Posts: 633
Location: PL
DaleStan wrote:
Are you quite sure that's not line noise? :p
I know this looks like ASCII-spaghetti :p but works well and I don't have to touch it.

BTW, my expression can find a lot of code that brakes coding style rules in whole OTTD project. In the current trunk search tool found 757 lines. More then 50% of them is not properly formatted code. The rest is some exceptions to coding style rules.

_________________
:] don't worry, be happy and checkout my patches


Top
   
PostPosted: Sat Sep 26, 2009 11:04 am 
Offline
Director
Director
User avatar

Joined: Mon Jan 14, 2008 3:51 pm
Posts: 633
Location: PL
I updated coding style wiki, indentation has been inconsistent. One time it has been made with tabs, another with two spaces, another with three spaces... some snippets have had one space before each line ...

Now it's the same as in properly formatted source code.

I have a proposition - maybe replace all tabs with:
Code:
 → 
(space, right arrow, space)

and spaces with:
Code:
·
(middle dot)

so people could see exactly which, where and how many whitespace characters are used?

_________________
:] don't worry, be happy and checkout my patches


Top
   
PostPosted: Wed Mar 30, 2011 7:01 am 
Offline
Director
Director
User avatar

Joined: Mon Jan 14, 2008 3:51 pm
Posts: 633
Location: PL
What about reference template arguments? i.e.
Code:
template <const int &Tvar> ... 
Are they considered as not supported by some compilers thus forbidden?
What are the guides for variable/function/member references as template arguments?

_________________
:] don't worry, be happy and checkout my patches


Top
   
PostPosted: Sat Oct 08, 2011 8:09 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Fri Mar 26, 2004 1:27 am
Posts: 1628
Location: Netherlands, Enschede
The link is broken, it links to http://wiki.openttd.org/Index.php/Coding_style

where it should link to: http://wiki.openttd.org/Coding_style

url rewrite, I guess ;)

_________________
Creator of the Openttd Challenge Spinoff, Town Demand patch
The path to riches, a report on playing on a daylength server on ultra hard mode.


Top
   
PostPosted: Sun Jul 21, 2013 12:43 am 
Offline
Engineer
Engineer

Joined: Wed Jun 26, 2013 6:07 am
Posts: 4
I wish to register a complaint. I wish to complain about this parrot, what I purchased not half an hour ago from this very boutique....

Oh, wait, sorry, wrong sketch. No, my complaint, which I freely admit may be too little too late, is about this portion of the style guideline:

Quote:
Global variables are preceded by an underscore. ("_")

This is a violation of the relevant ISO standards, which say that identifiers which start with an underscore are reserved for the implementation (compiler and standard libraries) at the global scope, and that identifiers which start with an underscore followed by a capital letter are reserved everywhere. Application programs are not allowed to use these names for globals.

Now, I admit that you've gotten away with it so far, and that fixing it at this late date may be more trouble than it's worth, but I think you should at least know that you're essentially relying on undefined behavior here. The compiler is perfectly within it's rights to translate every reference to any such global into system("/usr/local/games/nethack").

(In fact, one early version of gcc actually did that last with any #pragma it saw, simply to emphasize that a 100%-compiler-dependent "standard" feature gives you no guarantees of anything. I admit that it's unlikely that they'd do the same with identifiers that happen to start with underscore, but they could do so and still claim to have a standards-compliant compiler.)

Anyway, I guess I don't really object to you violating the international standards for the language, but I think it's important that you know you're violating the international yada yada. So, consider yourself informed. What you do with that knowledge is up to you.

references:
* Bjarne Stroustrup, The C++ Programming Language, Third Edition, Addison Wesley, 1997, pg 81.
* Ray Lischner, C++ in a Nutshell, O'Reilly & Associates, 2003, pg 3.

cheers


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 54 posts ]  Go to page Previous 1 2 3

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2017 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2017.
Hosted by Zernebok Hosting.