Jump to content


Photo

My patches and contribution


  • Please log in to reply
95 replies to this topic

#1 Tels

Tels

    Mod hero

  • Member
  • PipPipPipPipPip
  • 15024 posts

Posted 01 September 2014 - 11:11 AM

Moin,

since I no longer have SVN access, here are some patches and contributions for TDM. Hope this proves useful.

The post will be updated when things get either updated or commited. The source code diffs will be in unified form, and should apply cleanly. For the rest of the files, I'm unable to produce diffs, but hopefully merging the files is not too difficult.

If there are any questions or comments, feel free to post in this thread.

------------------------------
  • Patch A (2014-09-01, comitted by SteveL 2014-09-01) http://swift-mazes.c..._2014-09-01.txt
  • Description: Make TDM compile on Linux again. The TDM source uses true/false (lowercase) throughout, with a few libs as an exception. MSVC seem also to understand TRUE/FALSE, but lets keep the lower version for consistency.
  • Files: game/ai/Tasks/ResolveMovementBlockTask.cpp game/ai/AI.h game/Actor.cpp
------------------------------
  • German update (2014-08-08)
  • Description: Updates the German translation
  • Files: all.lang (The file german.lang is included just for reference, it should be regenerated by the script)
  • Size: 183 K
  • URL: http://swift-mazes.c..._2014-08-08.zip
  • Add Swedish (2014-09-01)
  • Description: Adds Swedish as an Menu Option
  • Files: strings/all.lang, strings/swedish.map, guis/mainmenu_settings_language.gui (The file swedish.lang is included just for reference, it should be regenerated by the script. all.lang is after the German update above)
  • Size: 187 K
  • URL: http://swift-mazes.c..._2014-09-01.zip

Edited by Tels, 03 September 2014 - 10:59 AM.

  • SeriousToni, nbohr1more and Kvorning like this
"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

"Remember: If the game lets you do it, it's not cheating." -- Xarax

#2 Bikerdude

Bikerdude

    Mod hero

  • Active Developer
  • PipPipPipPipPip
  • 17840 posts

Posted 01 September 2014 - 02:08 PM

@SteveL/Grayman/Greebo, when one of you guys get some time can you have a look at updating the SVN with the above code patches..?

ta.

#3 SteveL

SteveL

    Hero Coder

  • Active Developer
  • PipPipPipPip
  • 3657 posts

Posted 01 September 2014 - 03:20 PM

Thanks for the patches; Sure thing, I'll check them in.

#4 Obsttorte

Obsttorte

    Scripting guru, Mapper

  • Active Developer
  • PipPipPipPip
  • 4735 posts

Posted 01 September 2014 - 03:42 PM

What exactly got updated in the german translation (Patch 3)?
FM's: Builder Roads, Old Habits, Old Habits Rebuild
WIP's: Several. Although after playing Thief 4 I really wanna make a city mission.
Mapping and Scripting: Apples and Peaches
Sculptris Models and Tutorials: Obsttortes Models
My wiki articles: Obstipedia
Let's Map TDM YouTube playlist: ObstlerTube
Texture Blending in DR: DR ASE Blend Exporter

End of shameless self promotion.

#5 SteveL

SteveL

    Hero Coder

  • Active Developer
  • PipPipPipPip
  • 3657 posts

Posted 01 September 2014 - 03:53 PM

@Tels: does the all.lang in the Swedish update include the German updates too?

Update: tracked (3837) and committed (6096) A & B. I'll wait for you to confirm what to do with the language pack.

#6 Bikerdude

Bikerdude

    Mod hero

  • Active Developer
  • PipPipPipPipPip
  • 17840 posts

Posted 01 September 2014 - 04:30 PM

What exactly got updated in the german translation (Patch 3)?

oops sorry Obs, I forgot you do code based stuff for the mod. :blush:

#7 Obsttorte

Obsttorte

    Scripting guru, Mapper

  • Active Developer
  • PipPipPipPip
  • 4735 posts

Posted 02 September 2014 - 01:34 AM

:huh:
  • nbohr1more likes this
FM's: Builder Roads, Old Habits, Old Habits Rebuild
WIP's: Several. Although after playing Thief 4 I really wanna make a city mission.
Mapping and Scripting: Apples and Peaches
Sculptris Models and Tutorials: Obsttortes Models
My wiki articles: Obstipedia
Let's Map TDM YouTube playlist: ObstlerTube
Texture Blending in DR: DR ASE Blend Exporter

End of shameless self promotion.

#8 Tels

Tels

    Mod hero

  • Member
  • PipPipPipPipPip
  • 15024 posts

Posted 03 September 2014 - 10:53 AM

What exactly got updated in the german translation (Patch 3)?


Here is the diff:

Spoiler

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

"Remember: If the game lets you do it, it's not cheating." -- Xarax

#9 Tels

Tels

    Mod hero

  • Member
  • PipPipPipPipPip
  • 15024 posts

Posted 03 September 2014 - 10:55 AM

@Tels: does the all.lang in the Swedish update include the German updates too?

Update: tracked (3837) and committed (6096) A & B. I'll wait for you to confirm what to do with the language pack.


Thank you for the commits.

The all.lang from A is only the German fixes, B contains German + Swedish -it is just a section at the bottom - the menu entries for "Swedish" are already in TDM as of 2.02.
"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

"Remember: If the game lets you do it, it's not cheating." -- Xarax

#10 SteveL

SteveL

    Hero Coder

  • Active Developer
  • PipPipPipPip
  • 3657 posts

Posted 03 September 2014 - 11:38 AM

Thank you for the commits. The all.lang from A is only the German fixes, B contains German + Swedish -it is just a section at the bottom - the menu entries for "Swedish" are already in TDM as of 2.02.


Sorry, bit more clarity needed. Those are files, not patches. Do I have to merge them somehow before committing them, or does the all.lang from B include the changes to the all.lang from A?

#11 Tels

Tels

    Mod hero

  • Member
  • PipPipPipPipPip
  • 15024 posts

Posted 03 September 2014 - 12:11 PM

Sorry, bit more clarity needed. Those are files, not patches. Do I have to merge them somehow before committing them, or does the all.lang from B include the changes to the all.lang from A?


Yes, B does include A.

Sorry, but I can't really do patches, as I have no access to the current main SVN - only the v2.02 release.(and I'm not sure if diff handles UTF-8 and ISO-8859-1 correclty).

But what you could try is copy the new file over the old on in SVN, then do "SVN diff". That should show you the changes, and these should only be a few lines. If suddently the entire file changes, something is borked :)

The files "german.lang", "swedish.lang" are generated by a script (unless that was changed in the last year). The script is under devel/i18n/ IIRC. It might be that this script needs swedish being added as language so it knows to generte swedish.lang.
"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

"Remember: If the game lets you do it, it's not cheating." -- Xarax

#12 SteveL

SteveL

    Hero Coder

  • Active Developer
  • PipPipPipPip
  • 3657 posts

Posted 03 September 2014 - 12:34 PM

Yes, B does include A.

Sorry, but I can't really do patches,

Thanks, that's what I needed to know (B includes A).

Happy to report that your code patches worked flawlessly :) I was talking about the all.lang files when I said "they're not patches".

Sorry for not making myself clearer.

#13 Tels

Tels

    Mod hero

  • Member
  • PipPipPipPipPip
  • 15024 posts

Posted 03 September 2014 - 12:46 PM

Thanks, that's what I needed to know (B includes A).

Happy to report that your code patches worked flawlessly :) I was talking about the all.lang files when I said "they're not patches".

Sorry for not making myself clearer.


No problem, I understood it this way and was also talking about the .lang files. :) Thanx again!
"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

"Remember: If the game lets you do it, it's not cheating." -- Xarax

#14 Obsttorte

Obsttorte

    Scripting guru, Mapper

  • Active Developer
  • PipPipPipPip
  • 4735 posts

Posted 04 September 2014 - 02:21 AM

"#str_07323" "Halb blind;Normal;Schwer schwer" 
This looks like a mistake. I guess it should be
"#str_07323" "Halb blind;Normal;Schwer;Sehr schwer"
guessing from how the line for ai hearing looks like.
FM's: Builder Roads, Old Habits, Old Habits Rebuild
WIP's: Several. Although after playing Thief 4 I really wanna make a city mission.
Mapping and Scripting: Apples and Peaches
Sculptris Models and Tutorials: Obsttortes Models
My wiki articles: Obstipedia
Let's Map TDM YouTube playlist: ObstlerTube
Texture Blending in DR: DR ASE Blend Exporter

End of shameless self promotion.

#15 Tels

Tels

    Mod hero

  • Member
  • PipPipPipPipPip
  • 15024 posts

Posted 04 September 2014 - 10:28 AM

"#str_07323" "Halb blind;Normal;Schwer schwer"
This looks like a mistake. I guess it should be
"#str_07323" "Halb blind;Normal;Schwer;Sehr schwer"
guessing from how the line for ai hearing looks like.


You are right. Please correct it after putting the change in.
"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

"Remember: If the game lets you do it, it's not cheating." -- Xarax

#16 SteveL

SteveL

    Hero Coder

  • Active Developer
  • PipPipPipPip
  • 3657 posts

Posted 04 September 2014 - 01:11 PM

I'm having some crashing problems testing the language patch, so I've not committed anything. I'll zip up and PM you the existing svn files + the details in the hope you'll be able to see why. I don't know the i18n system.

#17 Tels

Tels

    Mod hero

  • Member
  • PipPipPipPipPip
  • 15024 posts

Posted 08 September 2014 - 10:38 AM

I've attached one patch and a testmap to http://bugs.thedarkm...iew.php?id=3823 - this adds the spawnargs "wait", "pass_self" and "pass_activator" to trigger_touch, so it is possible to rate-limit the calling frequency of the function, as well as get both the trigger and the activating entity in the call at the same time.

Edit: Updated the patches (wait can be negative, so took the checks out again) and added a third patch documenting the new spawnargs and one old: http://swift-mazes.c..._2014-09-08.txt

Edited by Tels, 08 September 2014 - 12:07 PM.

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

"Remember: If the game lets you do it, it's not cheating." -- Xarax

#18 Tels

Tels

    Mod hero

  • Member
  • PipPipPipPipPip
  • 15024 posts

Posted 08 September 2014 - 10:40 AM

I'm having some crashing problems testing the language patch, so I've not committed anything. I'll zip up and PM you the existing svn files + the details in the hope you'll be able to see why. I don't know the i18n system.


Steve, as written in the PM, do the crashes occur only because the "swedish.lang" file is missing? Generating this file with the command should fix it then - finding the crash is a seperate issue from the update then.
"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

"Remember: If the game lets you do it, it's not cheating." -- Xarax

#19 Tels

Tels

    Mod hero

  • Member
  • PipPipPipPipPip
  • 15024 posts

Posted 08 September 2014 - 11:18 AM

Here is another patch, repairing the linux build again. (In Linux, "ai/" and "AI/" are two different directories):

http://swift-mazes.c..._2014-09-08.txt
"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

"Remember: If the game lets you do it, it's not cheating." -- Xarax

#20 Tels

Tels

    Mod hero

  • Member
  • PipPipPipPipPip
  • 15024 posts

Posted 12 September 2014 - 08:04 AM

And here is another patch, this one adds the following script events to the sys object:

sys.strReplace( string input, string find, string replacewith );
sys.strRemove( string input, string find );
pos = sys.strFind( string input, string find, bool casesensitive, int start, int end);
sys.strToBool( string );

Includes documentation.

Here is an example:

 string test = "this is a test for a test";
 sys.println("1: " + test);
 string test1 = sys.strReplace(test, "test", "foo");
 sys.println("2: " + test1);
 string test2 = sys.strReplace(test1, "foo", "");
 sys.println("3: " + test2);
 string test3 = sys.strRemove(test2, " a ");
 sys.println("4: " + test3);
 float rc = sys.strFind(test3, "IS", 1,0,-1);
 sys.println("rc: " + rc);
 rc = sys.strFind(test3, "IS", 0,0,-1);
 sys.println("rc: " + rc);
 rc = sys.strFind(test3, " is ", 0,3,-1);
 sys.println("rc: " + rc);

 sys.println("expect 1:");
 sys.println("strToBool(1): " + sys.strToBool("1"));
 sys.println("strToBool(on): " + sys.strToBool("on"));
 sys.println("strToBool(On): " + sys.strToBool("On"));
 sys.println("strToBool(ON): " + sys.strToBool("ON"));
 sys.println("strToBool(true): " + sys.strToBool("true"));
 sys.println("strToBool(yes): " + sys.strToBool("yes"));
 sys.println("strToBool(enabled): " + sys.strToBool("enabled"));

 sys.println(""); sys.println("expect 0:");
 sys.println("strToBool(false): " + sys.strToBool("false"));
 sys.println("strToBool(off): " + sys.strToBool("off"));
 sys.println("strToBool(0): " + sys.strToBool("0"));
 sys.println("strToBool(no): " + sys.strToBool("no"));
 sys.println("strToBool(disabled): " + sys.strToBool("disabled"));

 sys.println(""); sys.println("expect -1:");
 sys.println("strToBool(2): " + sys.strToBool("2"));
 sys.println("strToBool(close): " + sys.strToBool("close"));
 sys.println("strToBool(): " + sys.strToBool(""));

It will print on the console:

1: this is a test for a test
2: this is a foo for a foo
3: this is a  for a
4: this is for
rc: -1
rc: 2
rc: 4
expect 1:
strToBool(1): 1
strToBool(on): 1
strToBool(On): 1
strToBool(ON): 1
strToBool(true): 1
strToBool(yes): 1
strToBool(enabled): 1

expect 0:
strToBool(false): 0
strToBool(off): 0
strToBool(0): 0
strToBool(no): 0
strToBool(disabled): 0

expect -1:
strToBool(2): -1
strToBool(close): -1
strToBool(): -1

http://swift-mazes.c..._2014-09-12.txt

One thing that this patch does not fix is the state of "boolean" and "int" in scripts. This is currently somewhat of a mess.

The script supports "bool variablename = true", but it seems the script compiler and the script event definitions do not yet support 'b'. There are other oddities like:
  • floats are 'f', but integers are 'd' instead of 'i'. ("d" reminds one of double, not integer. And there is no "d" in inteher :)
  • ReturnInt() says true integers are not supported and stores the return value in the float part - but variableDefs do contain an IntPtr. Adding true integer variable to the script compiler/interpreter would be nice, so you can actualy say "int variableName = 1".
  • In the same vain, ReturnBool() did not exist. So I added it, but it is currently unused, because it is not clear where the bool should be stored - IntPtr or FloatPtr? And a lot of script events that return a boolean have 'd', while others have 'f'. That should be fixed so that the correct return type is used according to function description, and both ReturnInt() and ReturnBool() do what they are supposed to do. Right now, all three ReturnXYZ() store the return value in the float part, so int,bool and float are all interchangable and are used differently all over the place.
That is for another day, tho.
"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

"Remember: If the game lets you do it, it's not cheating." -- Xarax

#21 grayman

grayman

    Master Builder, Coder

  • Active Developer
  • PipPipPipPipPip
  • 11494 posts

Posted 12 September 2014 - 09:26 AM

That is for another day, tho.


Whatever you're thinking of doing in that space, the result has to support the previous syntax.

Otherwise we'll have a problem with mission scripts and potentially anything in TDM's scripts that uses the old syntax.

#22 Tels

Tels

    Mod hero

  • Member
  • PipPipPipPipPip
  • 15024 posts

Posted 12 September 2014 - 09:59 AM

Whatever you're thinking of doing in that space, the result has to support the previous syntax.

Otherwise we'll have a problem with mission scripts and potentially anything in TDM's scripts that uses the old syntax.


Of course. However, there would be only two visible changes to scripts:

* the keyword "int" (or "integer") for variable types. This can't really clash with existing scripts, because "int foo = 1;" is not valid yet.
* the return types of script events might change from int to float - again, this will not impact existing scripts, as these use "float foo = sys.someFunc()" and if someFunc now returns an int 1 instead of float 1.0, this will silently be converted to float again.

The other two changes 'i' instead of 'd', and support for boolean as return values would not be visible to scripts again,as scripts either already use "bool b = sys.someFunc()", or they use "float b = sys.someFunc()" and get back 1 or 0, anyway.

A real patch with the changes to try would show if it works. But since it is a lot of work, I'd rather not start the work if nobody actually sees value in that.

That is why the current patch only adds non-controversial functions that are of value to mappers, but don't risk anything breaking.
"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

"Remember: If the game lets you do it, it's not cheating." -- Xarax

#23 SteveL

SteveL

    Hero Coder

  • Active Developer
  • PipPipPipPip
  • 3657 posts

Posted 12 September 2014 - 10:25 AM

I'm not convinced by strToBool and ReturnBool, given that the scripting language doesn't support a true boolean. The current situation isn't confusing imo -- all numbers are floats, and floats are used as bools too. The current script event strToFloat does the useful part of the strToBool job. Anyone touching the scripts will always recognise that 1=true, 0=false, but for any other mappings, surely it's better that scripts spell out the meaning right where they use it?

The other problem with the proposal is the list of keywords that get interpreted as bools. Presumably they'd be hard-coded in game code. I fear that'll make for much more confusing scripts. If people want to use keywords they can #define them in their own script headers, where the definitions will be easy to find for anyone reading the script. If you map a dozen magic words to true and false in the game code, it just means people have to look them up. No-one will remember that "off" maps to 0 but "close" maps to -1. I'm finding it a bit confusing already. Is it that -1 is supposed to represent a NULL boolean, neither true nor false? And that "close" is an example of an unmapped keyword?

strFind and strReplace look useful. There's currently no easy and efficient way to do those things.

#24 Tels

Tels

    Mod hero

  • Member
  • PipPipPipPipPip
  • 15024 posts

Posted 12 September 2014 - 10:42 AM

I'm not convinced by strToBool and ReturnBool, given that the scripting language doesn't support a true boolean.


What the scripting language does syntax wise,and how it is implemented internally are two different things. Actually, the scripting language does support bool:

bool foo = true;
if (foo)
  {
  // do something
  }

And there is also support for "spawnargs.getBoolKey()" and so on.

It is just that the code in C++ is incomplete and not finished. F.i. there is "ReturnInt()" and as a coder it is quite confusing if there isn't a "ReturnBool()", too. The interface is just incomplete. And my patch is one step of making it more complete.

I can take that part out, if you wish.

The current situation isn't confusing imo -- all numbers are floats, and floats are used as bools too. The current script event strToFloat does the useful part of the strToBool job. Anyone touching the scripts will always recognise that 1=true, 0=false, but for any other mappings, surely it's better that scripts spell out the meaning right where they use it?


Actually, the interface already supports ReturnInt() - it just stuffs the result into a float - but that is merely a "TODO", "FIXME" etc item. The current code comments even talk in some cases about things that are no longer true.

ReturnBool() is just the first step at unifying the interface. (Edit: And it reads and looks much more cleaner to use ReturnBool( true ) as ReturnFloat( 1.0f ) - the same reason we have ReturnInt( 1 ). Convience for the coder. End of edit.)

The other problem with the proposal is the list of keywords that get interpreted as bools. Presumably they'd be hard-coded in game code. I fear that'll make for much more confusing scripts. If people want to use keywords they can #define them in their own script headers, where the definitions will be easy to find for anyone reading the script. If you map a dozen magic words to true and false in the game code, it just means people have to look them up. No-one will remember that "off" maps to 0 but "close" maps to -1. I'm finding it a bit confusing already. Is it that -1 is supposed to represent a NULL boolean, neither true nor false? And that "close" is an example of an unmapped keyword?


I knew someone would object to the list of keywords. We already have such a sitatuion with "-" and "" - both are used as "don't use" but the code not always recognises "-" as empty.

As for "strToBool()", well, the current getBoolKey() is incomplete, too. It only supports "1" and "0". But sometimes people might "true" in spawnargs, or options. Parsing such values in the scripting language is very cumbersome and slow (multiple passes between scripting and C++).

But I can take it out, if you wish. Emulating it in script will be deadslow, but possible.

strFind and strReplace look useful. There's currently no easy and efficient way to do those things.


Edited by Tels, 12 September 2014 - 10:45 AM.

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

"Remember: If the game lets you do it, it's not cheating." -- Xarax

#25 Tels

Tels

    Mod hero

  • Member
  • PipPipPipPipPip
  • 15024 posts

Posted 12 September 2014 - 10:48 AM

Patch updated and StrToBool() and ReturnBool() removed.
"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

"Remember: If the game lets you do it, it's not cheating." -- Xarax




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users