Requested hacks

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
narabedla
Engineer
Engineer
Posts: 4
Joined: 18 May 2006 14:54

Requested hacks

Post by narabedla »

I've made a few rough patches (i.e. hacks, they're not intended to be permanent changes to code, I don't promise they'll work, but should be okay) to do things that have been requested. I'll do some more if I have the time to spare.

I'm rather limited on what software I can run on this computer, so the patch files have been assembled by hand somewhat. Apologies if the patch software you use doesn't understand them, they work fine with Cygwin's patch - so I'm guessing (hopeing) they'll be okay.

-----
Hack: Allow mail trucks to use truck stops and bus stops.
Attachments
mail_trucks(r4943).diff
Allow mail trucks to use truck AND bus stops (r4943).
(5.11 KiB) Downloaded 296 times
narabedla
Engineer
Engineer
Posts: 4
Joined: 18 May 2006 14:54

Post by narabedla »

Hack: Allow more than 40 orders for each vehicle.

Problems: Saving of orders when deleteing a vehicle so that the next vehicle built has the same orders as the old one has been disabled. To get around this problem you'll have to built new vehicle first, copy the orders, then delete old vehicle.
Attachments
more_orders(r4943).diff
Allow more than 40 orders for each vehicle (r4943).
(2.18 KiB) Downloaded 250 times
peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1791
Joined: 30 Mar 2005 09:43

Post by peter1138 »

Please make unified diffs (-u)... They're a lot easier to keep track of.
He's like, some kind of OpenTTD developer.
User avatar
belugas
OpenTTD Developer
OpenTTD Developer
Posts: 1507
Joined: 05 Apr 2005 01:48
Location: Deep down the deepest blue
Contact:

Post by belugas »

And also, use coding style as much as possible :

un-needed change. It should stay the same

Code: Select all

-      if (v->cargo_type == CT_PASSENGERS) {
+                  if (v->cargo_type == CT_PASSENGERS)
+ 	 					{
Wrong coding style

Code: Select all

-      } else {
+      }
+            else if (v->cargo_type == CT_MAIL)
+      {
Should have been

Code: Select all

-      } else {
+      } else if (v->cargo_type == CT_MAIL) {
If you are not ready to work a bit for your ideas, it means they don't count much for you.
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones
Ryalla
Engineer
Engineer
Posts: 19
Joined: 15 Apr 2006 06:13

Post by Ryalla »

Despite the aforementioned errors, I personally like the order limit hack. Sounds great!
User avatar
bobingabout
Tycoon
Tycoon
Posts: 1850
Joined: 21 May 2005 15:10
Location: Hull, England

Post by bobingabout »

to me, thats like, woah!!! Braces should have their own lines :shock:
but then i've never programmed anything in ottd.
JPG SUX!!! USE PNG!!!
There are times when JPG is useful, TTD screenshots is not one of them. Please use PNG instead.

[/url]
User avatar
Thief^
Route Supervisor
Route Supervisor
Posts: 469
Joined: 10 Oct 2004 00:11

Post by Thief^ »

bobingabout wrote:to me, thats like, woah!!! Braces should have their own lines :shock:
but then i've never programmed anything in ottd.
Well I agree, but ottd has an official coding style and we should stick to it, regardless of how far against our own personal tastes it is.
Melt with the Shadows,
Embrace your destiny...
User avatar
belugas
OpenTTD Developer
OpenTTD Developer
Posts: 1507
Joined: 05 Apr 2005 01:48
Location: Deep down the deepest blue
Contact:

Post by belugas »

Indeed :)

I would rather go as this :

Code: Select all

Function GetMeSomethingToDo( Value : integer) : Integer;
Begin
   Result := 0;
   While Result <> Value Do
      Begin
         Result := GetSomeCode;
         SaveLog(Result, Value);
      End;
End;
but... well... won't compile in C and would be rejected quite fast ;)
If you are not ready to work a bit for your ideas, it means they don't count much for you.
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones
peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1791
Joined: 30 Mar 2005 09:43

Post by peter1138 »

You should be banned. Under some Geneva convention.

That's not code.
That's pseudo code!
He's like, some kind of OpenTTD developer.
User avatar
LKRaider
Transport Coordinator
Transport Coordinator
Posts: 360
Joined: 23 Mar 2005 04:05
Location: Brasil
Contact:

Post by LKRaider »

That's Delphi (Object Pascal) ! :P
User avatar
belugas
OpenTTD Developer
OpenTTD Developer
Posts: 1507
Joined: 05 Apr 2005 01:48
Location: Deep down the deepest blue
Contact:

Post by belugas »

LKRaider wrote:That's Delphi (Object Pascal) ! :P
Finally, a real programmer!
I am not alone anymore!!! :lol:
If you are not ready to work a bit for your ideas, it means they don't count much for you.
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones
MattW
Engineer
Engineer
Posts: 14
Joined: 14 Mar 2006 16:10

Post by MattW »

No it's not, nothing in there screams Delphi to me... it's just Pascal. And that's not a real language either.

Code: Select all

int getMeSomethingToDo(int value) {
  int result = 0;
  while (result != value) {
    result = getSomeCode();
    saveLog(result, value);
  }
  return result;
}
User avatar
belugas
OpenTTD Developer
OpenTTD Developer
Posts: 1507
Joined: 05 Apr 2005 01:48
Location: Deep down the deepest blue
Contact:

Post by belugas »

MattW wrote:No it's not, nothing in there screams Delphi to me... it's just Pascal.
This line will tell you it is Object Pascal.
Assigning the return value of a function by the key word "Result" is typical.

Code: Select all

Result := GetSomeCode;
In standard pascal, you'll do

Code: Select all

i := GetSomeCode;
...
GetMeSomethingToDo := i;
Or something alike.
And since (to my knowledge) Delphi is the only Pascal compiler to use Object Pascal...
MattW wrote:And that's not a real language either.
Another one frustrated of not able to use (and recognize) a TRUE beautiful language :D

Although I have to admit I begin to like C more and more.
But I keep my day job in Delphi ;)
If you are not ready to work a bit for your ideas, it means they don't count much for you.
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones
MattW
Engineer
Engineer
Posts: 14
Joined: 14 Mar 2006 16:10

Post by MattW »

I used to be a Delphi programmer... never professionally though. I have a bit of a soft spot for it, but then I discovered the joy of C++, and then even more so the sheer bloody-minded purity that is Haskell.

Wouldn't want to write a game in Haskell though.
User avatar
bobingabout
Tycoon
Tycoon
Posts: 1850
Joined: 21 May 2005 15:10
Location: Hull, England

Post by bobingabout »

i just love CAOS, unfortunatly, its only a scripting language for the CAOS engine, which is kinda crap...
JPG SUX!!! USE PNG!!!
There are times when JPG is useful, TTD screenshots is not one of them. Please use PNG instead.

[/url]
Moriarty
Tycoon
Tycoon
Posts: 1395
Joined: 12 Jun 2004 00:37
Location: United Kingdom of Great Britain and Northern Ireland
Contact:

Post by Moriarty »

THere's nothing quite as unique (and fairly entertaining) as watching programmers disagree as to what makes a "real" language. ;)

Personally I think someone should fork off the entire OTTD code-base to create a "clean" version that has brackets on their own lines where they belong. :D
Hazelrah
Traffic Manager
Traffic Manager
Posts: 196
Joined: 13 Apr 2005 05:41

Post by Hazelrah »

Moriarty wrote:...brackets on their own lines where they belong. :D
I used to think that, and then I realized... you know, if it's consistant coding style it takes about 5 minutes to learn the rules and everythings good! The real problem comes in when somebody thinks their way is the only way and goes against the rules.


-Hazelrah
User avatar
Korenn
Tycoon
Tycoon
Posts: 1735
Joined: 26 Mar 2004 01:27
Location: Netherlands
Contact:

Post by Korenn »

I don't think the placement of brackets really falls under coding style, it's too trivial. If your editor is advanced enough, it will automatically handle bracket stuff.

I think coding style has more to do with code content, things like optimization, use of (x?y:z) statements, use of increments etc. Those can really determine whether code is readable or not, while brackets are always brackets (readability ofcourse being an entirely subjective matter)
User avatar
bobingabout
Tycoon
Tycoon
Posts: 1850
Joined: 21 May 2005 15:10
Location: Hull, England

Post by bobingabout »

like a variable in a pascal program for an assignment i wrote called "somepeiceofcrapicantbearsedtoname"

it was 3 in the morning when i was writing it, and it was a last minute addition to get the function to work properly.
JPG SUX!!! USE PNG!!!
There are times when JPG is useful, TTD screenshots is not one of them. Please use PNG instead.

[/url]
User avatar
Korenn
Tycoon
Tycoon
Posts: 1735
Joined: 26 Mar 2004 01:27
Location: Netherlands
Contact:

Post by Korenn »

No, actually the name of a variable has also become a trivial thing, but that has happened only recently. Up to date editors can change the name of a variable in the blink of an eye, correctly and only in the right places. (so it knows that "x" in one place might not be the same "x" in another).

Code obfuscators are actually becoming common place, and are becoming workarounds around open source demands. (You can release your code, but if it's unreadable to humans, it's not going to help the competition at all).

I think code style is becoming more abstract, having to do with design issues, how you tackle a problem. You could e.g. code a routine using object oriented techniques, assembler, basic-like stuff or something altogether different. With a modern and efficient compiler, it might very well all amount to the same executable machine code.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Google [Bot] and 11 guests