Page 1 of 1

Requested hacks

Posted: 23 May 2006 15:01
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.

Posted: 23 May 2006 15:04
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.

Posted: 23 May 2006 16:03
by peter1138
Please make unified diffs (-u)... They're a lot easier to keep track of.

Posted: 23 May 2006 16:42
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) {

Posted: 23 May 2006 20:55
by Ryalla
Despite the aforementioned errors, I personally like the order limit hack. Sounds great!

Posted: 24 May 2006 09:32
by bobingabout
to me, thats like, woah!!! Braces should have their own lines :shock:
but then i've never programmed anything in ottd.

Posted: 24 May 2006 17:59
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.

Posted: 24 May 2006 19:07
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 ;)

Posted: 24 May 2006 19:24
by peter1138
You should be banned. Under some Geneva convention.

That's not code.
That's pseudo code!

Posted: 25 May 2006 20:08
by LKRaider
That's Delphi (Object Pascal) ! :P

Posted: 25 May 2006 20:15
by belugas
LKRaider wrote:That's Delphi (Object Pascal) ! :P
Finally, a real programmer!
I am not alone anymore!!! :lol:

Posted: 26 May 2006 14:56
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;
}

Posted: 26 May 2006 15:13
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 ;)

Posted: 06 Jun 2006 14:21
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.

Posted: 06 Jun 2006 15:04
by bobingabout
i just love CAOS, unfortunatly, its only a scripting language for the CAOS engine, which is kinda crap...

Posted: 06 Jun 2006 20:28
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

Posted: 07 Jun 2006 06:20
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

Posted: 07 Jun 2006 19:49
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)

Posted: 08 Jun 2006 08:45
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.

Posted: 08 Jun 2006 20:20
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.