PDA

View Full Version : preGSC



iCore
11th November 2013, 21:53
Hey!

I just want your opinion about a new tool I'm making.
It is basically a GSC preprocessor, which will let us use new syntax elements in GSC scripting.
Currently it support condition operator (level.speed = amount > 50 ? 100 : 25), and reference variables (&p = level.players[i]).

It picks up the GSCs from the folder you are working in (with for example shorthand ifs and references), transforms them to proper GSC syntax which can be read by CoD, and saves to an output folder (for example I'm working in the 'source' folder, and compiling into 'maps'). It is also very fast, so it doesn't even slow down compiling. It is available on both Windows and Linux, and hopefully compatible with all CoD versions which are using GSC. A much better description, instructions, parameters, and the file itself can be found here: http://www.moddb.com/downloads/pregsc.

I hope you gonna like it, every suggestion or opinion are welcome!

Also I'm planning more language elements, tell me if you miss anything from GSC, or if you think something could make the coding more comfortable!

Tally
11th November 2013, 22:12
There is no such thing as "GSC scripting". .GSC is a file format. Not a language. It's as ridiculous to refer to "GSC Scripting" as it is to refer to "ZIP Scripting".

The language used in COD scripting is usually referred to as COD Script. Certainly, the developers of COD refer to it that way.

Other than that, good luck with your project.

BTW - if you ever wondered what G.S.C. means, it is the initials of Grant Stuart Collier, former President of Infinity Ward. This was told to me directly by Grant, the first time I met him in person.

iCore
11th November 2013, 22:17
There is no such thing as GSC scripting. .GSC is a file format. Not a language. It's as ridiculous to refer to "GSC Scripting" as it is to refer to "ZIP Scripting". The language used in COD scripting is usually referred to as COD Script.

BTW - if you ever wondered what G.S.C. means, it is the initials of Grant Stuart Collier, former President of Infinity Ward.
Let me keep calling it that way, I think GSC is only used in CoD, and it is much clearer that "CoD scripting", since many people outta there calling "menu editing" as "menu scripting" too. So saying CoD scripting wouldn't be obvious enough for everyone. However that's probably true what you say, but I think it does not matter until I'm not writing an official letter to IW (also I thought it is Game SCript :D)

Tally
11th November 2013, 22:50
Let me keep calling it that way, I think GSC is only used in CoD, and it is much clearer that "CoD scripting", since many people outta there calling "menu editing" as "menu scripting" too. So saying CoD scripting wouldn't be obvious enough for everyone. However that's probably true what you say, but I think it does not matter until I'm not writing an official letter to IW (also I thought it is Game SCript :D)

Very few computer languages give their name to a file format. PHP is one. I'm sure you can think of others. But there are more that don't. For example, C and C++ do not, neither does Python, nor does Cobal. However, if you want to keep doing it, then obviously I can't stop you.

BTW - you say you thought it stood for Game Script. But what does the "c" stand for? Game Script Code? That doesn't even sound right.

kung foo man
12th November 2013, 09:17
This reminds me pretty much of this discussion :D http://modsonline.com/Forums-top-158856-10.html

I always wanted #ifdef and co to circumvent version depending errors (e.g. "function not found" from 1.3 to 1.2 server).

You could use the .menu parser from Enemy Territory (GPL and free to download game files, "parent" of CoD1): https://github.com/mgrdcm/ET-GPL/blob/master/src/extractfuncs/l_precomp.c (might be just easier to write the needed parts yourself)

Where we can find your current source code?

iCore
12th November 2013, 10:41
BTW - you say you thought it stood for Game Script. But what does the "c" stand for? Game Script Code? That doesn't even sound right.
No, I thought it is Game SCript (2 letters from SCript :D)


I always wanted #ifdef and co to circumvent version depending errors (e.g. "function not found" from 1.3 to 1.2 server).

You could use the .menu parser from Enemy Territory (GPL and free to download game files, "parent" of CoD1): https://github.com/mgrdcm/ET-GPL/blob/master/src/extractfuncs/l_precomp.c (might be just easier to write the needed parts yourself)

Where we can find your current source code?

Currently I didn't share the source code yet, but it'll be on GitHub soon :)
Also I'm really a beginner in C++, my programming logic is okay for writing the algorithm, but I'm dumb for sure to understand that menu parser :P Also I was never working with any parsers yet so also my current code is really gay :> But anyhow, it is ultrafast, so it's not a big problem currently :D
And if you mean #define, ifdef, ifndef, etc in "CoD Script", then I'll check what can I do with them ^^

iCore
12th November 2013, 14:06
I always wanted #ifdef and co to circumvent version depending errors (e.g. "function not found" from 1.3 to 1.2 server).

So here it is: http://mezesmadzag.hu/preGSC.zip

Usage is the same as in CoD Menu:
#define KUNG
#undef KUNG
#ifdef KUNG
#ifndef KUNG
#else
#endif

I hope it is working perfectly, I have tested some critical conditions, but please sign back if it does or not :)

kung foo man
12th November 2013, 14:25
Huh, a binary?

I thought you hooked FS_FOpenFile, FS_Read etc. to parse .gsc-files on the fly.

iCore
12th November 2013, 14:33
Huh, a binary?

I thought you hooked FS_FOpenFile, FS_Read etc. to parse .gsc-files on the fly.

Uhhh, no, you haven't even read about it on ModDB :(
I can hook nothing, especially not in C, nor do I have Assembly knowledge.
Also Ninja said it'd be much work for him too to modify GSC syntax on server side.

At least this way it doesn't require any modification on the server :>

kung foo man
12th November 2013, 14:48
Sorry, I didn't saw the moddb link :D



You can see, it is now as readable as the original version, but without any copying, since it will be converted to the optimal version. It makes this code also fast and nice.You can see, it is now as readable as the original version, but without any copying, since it will be converted to the optimal version. It makes this code also fast and nice.


Do you just think that, because the code is shorter (not using helper-variables), or did you actually test it?

iCore
12th November 2013, 15:20
Do you just think that, because the code is shorter (not using helper-variables), or did you actually test it?

Sadly I can't test that properly since I can't measure the passed milliseconds :/
But if you know a way to do it (even maybe with server file), that'd be great to check.
The only way I know is to execute it millions of times and check the hitch warning; but I think that's really not an exact solution.

iCore
16th November 2013, 22:17
Okay so now I have extended those preprocessor directives to be more useful, and also added some more things. Changelog:
[+] Preprocessor directives
[+] Inline functions
[+] Foreach
[+] Filled array and map definitions
[+] Default parameters
[+] Apostrophe strings
[+] Importing
[-] Handling more extreme conditions

I hope it'll be useful for someone. Download: preGSC (http://www.moddb.com/games/call-of-duty/downloads/pregsc)
Please report every ideas and bugs.

Also kung foo I have benchmarked many things, reference variables are really not useful when using as a constant (so not modifying the data structure itself), also sometimes helper variables are faster (I see no logic behind it, asked BraXi and Ninja and noone knows why, but these were the test results), so I have made inline functions with which we can save much copying (details on ModDB page - no real function call, it will be inserted in the code while compiling with preGSC); I have run 100000 times a removeFromArray function with normal function, and with inline. Normal was 4000ms, inline was 500ms... so thanks for the benchmarking idea.

IzNoGoD
16th November 2013, 23:09
I take it foreach doesnt work with string-arrays in cod2? For afaik there is no way to get all keys() from such an array...

iCore
17th November 2013, 10:32
I take it foreach doesnt work with string-arrays in cod2? For afaik there is no way to get all keys() from such an array...

Ooooooh, no getArrayKeys() in CoD2? :S
Fuuuu :(

iCore
17th November 2013, 19:36
I take it foreach doesnt work with string-arrays in cod2? For afaik there is no way to get all keys() from such an array...

Okay now (in a non-released version) I have enhanced foreach() in several ways. With the -zeroarrays parameter you'll be able to tell the program to generate 0-indexed loops instead of using getArrayKeys().
Even if you are using -zeroarrays or not, you'll be able to pass parameters this way: foreach (player in level.players; 1; n) where 1 means the starting index, and n is size of the array. They are not compulsory, but if starting index is set, then nor without -zeroarrays will getArrayKeys be generated. Also there is must optimization based on much benchmarking, like creating pointer to an element if used more than 2 times inside the loop, etc.

Now it may be a little meaningless description, but I'll serve many examples on the ModDB page when released, containing the usage of parameter and the details of optimizations too.

By the way thanks for reporting that problem.

Cheers.

kung foo man
3rd December 2013, 20:14
Hows the source, luke?

iCore
3rd December 2013, 20:28
I'll make that public when releasing the newest version soon :)
But also that code will be ugly and shit for an experienced C++ programmer so don't be scared when you see that :D

kung foo man
9th April 2014, 18:13
690
(ten chars)

php
9th April 2014, 21:19
http://cod1.eu/gif/coffeebob.gif

iCore
9th April 2014, 21:50
Lol sorry it was forgotten xD
Here you are: preGSC source (https://github.com/SharpKode/preGSC)
It is not done by a real compiler with lexical-syntax-semantical analysis, I wanted it to be as fast as possible.