Giter Site home page Giter Site logo

xensik / gsc-tool Goto Github PK

View Code? Open in Web Editor NEW
207.0 16.0 36.0 32.96 MB

A utility to compile & decompile IW engine game scripts.

License: GNU General Public License v3.0

Lua 0.02% C++ 99.98% Makefile 0.01% Dockerfile 0.01%
cod callofduty engine mod scripts gsc compiler decompiler modern warfare

gsc-tool's Introduction

sonar build issues license releases paypal

GSC Tool

A utility to compile & decompile IW engine game scripts.

Supported Games

  • IW5 (Call of Duty: Modern Warfare 3) PC PS3 Xbox 360
  • IW6 (Call of Duty: Ghosts) PC PS3 PS4 Xbox 360 Xbox One
  • IW7 (Call of Duty: Infinite Warfare) PC PS4 Xbox One
  • IW8 (Call of Duty: Modern Warfare (2019) / Warzone) PC PS4 PS5 Xbox One Xbox Series X|S
  • IW9 (Call of Duty: Modern Warfare II (2022) / Warzone 2) PC PS4 PS5 Xbox One Xbox Series X|S
  • S1 (Call of Duty: Advanced Warfare) PC PS3 PS4 Xbox 360 Xbox One
  • S2 (Call of Duty: WWII) PC PS4 Xbox One
  • S4 (Call of Duty: Vanguard) PC PS4 PS5 Xbox One Xbox Series X|S
  • H1 (Call of Duty: Modern Warfare Remastered) PC PS4 Xbox One
  • H2 (Call of Duty: Modern Warfare 2 Campaign Remastered) PC PS4 PS5 Xbox One Xbox Series X|S
  • T6 (Call of Duty: Black Ops II) PC PS3 Xbox 360 Wii U
  • T7 (Call of Duty: Black Ops III) PC (Decompiler)
  • T8 (Call of Duty: Black Ops 4) *WIP*
  • T9 (Call of Duty: Black Ops Cold War) *WIP*
  • JUP (Call of Duty: Modern Warfare III (2023) *WIP*

Usage

gsc-tool [OPTIONS..] <path>

  • path: file or directory to process

  • options:

    -m, --mode <mode> [REQUIRED] one of: asm, disasm, comp, decomp, parse

    -g, --game <game> [REQUIRED] one of: iw5, iw6, iw7, iw8, iw9, s1, s2, s4, h1, h2, t6 t7 t8 t9 jup

    -s, --system <system> [REQUIRED] one of: pc, ps3, ps4, ps5, xb2 (360), xb3 (One), xb4 (Series X|S), wiiu

    -d, --dev Enable developer mode (dev blocks & generate bytecode map).

    -z, --zonetool Enable zonetool mode (use .cgsc files).

    -h, --help Display help.

    -v, --version Display version.

Example: gsc-tool -m comp -g iw5 -s pc ./data/iw5/my_fancy_script.gsc

Mode Description Output
asm assemble a file.gscasm file.gscbin
disasm dissasemble a file.gscbin file.gscasm
comp compile a file.gsc file.gscbin
decomp decompile a file.gscbin file.gsc
parse parse a file.gsc file.gsc

File Format

If you need to extract scripts from fastfiles or game memory, use Zonetool or Jekyll.

  • gsc-tool .gscbin binary format is a serialized ScriptFile struct:

    • magic: "GSC\0" 4 byte
    • compressedLen: 4 byte usigned integer
    • len: 4 byte usigned integer
    • bytecodeLen: 4 byte usigned integer
    • buffer: byte array[compressedLen]
    • bytecode: byte array[bytecodeLen]

note: for PS3 & Xbox 360 .gscbin files (compressedLen, len, bytecodeLen) are saved as little-endian!!

  • zonetool (IW5) format made of bytecode file .cgsc and decompressed stack buffer .cgsc.stack.

  • treyarch (T6) format is a single buffer with gscobj data .gsc or .csc.

Build

  • install premake5 on your system PATH
  • clone this repository
  • update the submodules git submodule update --init --recursive
  • run prebuild script premake5 vs2022 (windows) or premake5 gmake2 (linux/macos)

Contribute

If you like my work, consider sponsoring/donating! Would allow me to spend more time adding new features & fixing bugs.

BTC: bc1qky7x9kpjlt6nsvt7pckc3wwzk8rk9pgtnmw98u
ETH: 0x6261BBE1a33F6Fec4b722DbCe2c28B4CC02c9C7B
pypl kofi

Credits

This project is based on RektInator's gsc-asm. Special thanks to RektInator, JTAG & Dasfonia.

Disclaimer

This software has been created purely for the purposes of academic research. Project maintainers are not responsible or liable for misuse of the software. Use responsibly.

gsc-tool's People

Contributors

3ldor avatar clementdreptin avatar dependabot[bot] avatar diamante0018 avatar ineedbots avatar joelrau avatar mjkzy avatar simonlfc avatar skiff avatar xensik avatar xerxes-at avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gsc-tool's Issues

Add an optional parameter at the end to specify output file name

Basically

gsc-tool <mode> <game> <system> <path> (output-path)

Example

gsc-tool comp t6 pc script.gsc "../../storage/t6/scripts/mp/script.gsc"

This would remove the tedious step of manually copying the file every time (or having to run a bat file every time)

"assembler: couldn't resolve label address" when compiling jumps or switches for t6.

As an example, when using using gsc-tool.exe comp t6 pc test\gsc-tool-1_0_667_for.gsc, while the gsc contains a valid for loop,
will give you the following error:
[ERROR]:assembler: couldn't resolve label address of loc_3 at test/gsc-tool-1_0_667_for.gsc

Seems to affect for, while, foreach, if, and switches.

Attaching sample scripts with each of the above that replicate the problem

Output from these files:

[ERROR]:assembler: couldn't resolve label address of loc_3 at test/gsc-tool-1_0_667_assembler_for.gsc
[ERROR]:assembler: couldn't resolve label address of loc_1 at test/gsc-tool-1_0_667_assembler_foreach.gsc
[ERROR]:assembler: couldn't resolve label address of loc_1 at test/gsc-tool-1_0_667_assembler_if.gsc
[ERROR]:assembler: couldn't resolve label address of loc_1 at test/gsc-tool-1_0_667_assembler_switch.gsc
[ERROR]:assembler: couldn't resolve label address of loc_1 at test/gsc-tool-1_0_667_assembler_while.gsc

Other modes and systems have not been attempted to see if they have the same outcome.

When attempting to debug, an assert fails while in the for loop in assemble_function

auto assembler::assemble_function(function& func) -> void

image

test.zip

Grammar railroad diagram

Using this tool https://www.bottlecaps.de/convert/ and manually adding the tokens from gsc-tool/blob/3d94bb6fb9d6169fbe19f047e94859317fd008fa/gen/h1/lexer.lpp we can see a railroad diagram for the grammar in gsc-tool/3d94bb6fb9d6169fbe19f047e94859317fd008fa/gen/h1/parser.ypp copy and paste the EBNF shown bellow on https://www.bottlecaps.de/rr/ui in the tab Edit Grammar then switching to the tab View Diagram.

/*
From https://raw.githubusercontent.com/xensik/gsc-tool/3d94bb6fb9d6169fbe19f047e94859317fd008fa/gen/h1/parser.ypp
*/

/* converted on Mon Jul 12, 2021, 11:55 (UTC+02) by bison-to-w3c v0.52 which is Copyright (c) 2011-2021 by Gunther Rademacher <[email protected]> */

root     ::= ( include | define )*
include  ::= INCLUDE file SEMICOLON
define   ::= usingtree
           | constant
           | thread
usingtree
         ::= USINGTREE LPAREN string RPAREN SEMICOLON
constant ::= name ASSIGN expr SEMICOLON
thread   ::= name LPAREN name? ( COMMA name )* RPAREN stmt_block
stmt     ::= stmt_block
           | stmt_call
           | stmt_assign
           | stmt_endon
           | stmt_notify
           | stmt_wait
           | stmt_waittill
           | stmt_waittillmatch
           | stmt_waittillframeend
           | stmt_waitframe
           | stmt_if
           | stmt_ifelse
           | stmt_while
           | stmt_for
           | stmt_foreach
           | stmt_switch
           | stmt_case
           | stmt_default
           | stmt_break
           | stmt_continue
           | stmt_return
           | stmt_breakpoint
           | stmt_prof_begin
           | stmt_prof_end
stmt_block
         ::= LBRACE stmt* RBRACE
stmt_call
         ::= ( expr_call | expr_call_thread ) SEMICOLON
stmt_assign
         ::= expr_assign SEMICOLON
stmt_endon
         ::= object ENDON LPAREN expr RPAREN SEMICOLON
stmt_notify
         ::= object NOTIFY LPAREN expr ( COMMA expr_arguments )? RPAREN SEMICOLON
stmt_wait
         ::= WAIT expr SEMICOLON
stmt_waittill
         ::= object WAITTILL LPAREN expr ( COMMA expr_arguments )? RPAREN SEMICOLON
stmt_waittillmatch
         ::= object WAITTILLMATCH LPAREN expr ( COMMA expr_arguments )? RPAREN SEMICOLON
stmt_waittillframeend
         ::= WAITTILLFRAMEEND SEMICOLON
stmt_waitframe
         ::= WAITFRAME ( LPAREN RPAREN )? SEMICOLON
stmt_if  ::= IF LPAREN expr RPAREN stmt
stmt_ifelse
         ::= IF LPAREN expr RPAREN stmt ELSE stmt
stmt_while
         ::= WHILE LPAREN expr RPAREN stmt
stmt_for ::= FOR LPAREN for_stmt SEMICOLON for_expr SEMICOLON for_stmt RPAREN stmt
stmt_foreach
         ::= FOREACH LPAREN name ( COMMA name )? IN expr RPAREN stmt
stmt_switch
         ::= SWITCH LPAREN expr RPAREN stmt_block
stmt_case
         ::= CASE ( integer | neg_integer | string ) COLON
stmt_default
         ::= DEFAULT COLON
stmt_break
         ::= BREAK SEMICOLON
stmt_continue
         ::= CONTINUE SEMICOLON
stmt_return
         ::= RETURN expr? SEMICOLON
stmt_breakpoint
         ::= BREAKPOINT SEMICOLON
stmt_prof_begin
         ::= PROFBEGIN LPAREN expr_arguments RPAREN SEMICOLON
stmt_prof_end
         ::= PROFEND LPAREN expr_arguments RPAREN SEMICOLON
for_stmt ::= expr_assign?
for_expr ::= expr?
expr     ::= expr_compare
           | expr_binary
           | expr_primitive
expr_assign
         ::= ( INCREMENT | DECREMENT ) object
           | object ( INCREMENT | DECREMENT | ( ASSIGN | ASSIGN_BITWISE_OR | ASSIGN_BITWISE_AND | ASSIGN_BITWISE_EXOR | ASSIGN_LSHIFT | ASSIGN_RSHIFT | ASSIGN_ADD | ASSIGN_SUB | ASSIGN_MULT | ASSIGN_DIV | ASSIGN_MOD ) expr )
expr_compare
         ::= expr ( OR | AND | EQUALITY | INEQUALITY | LESS_EQUAL | GREATER_EQUAL | LESS | GREATER ) expr
expr_binary
         ::= expr ( BITWISE_OR | BITWISE_AND | BITWISE_EXOR | LSHIFT | RSHIFT | ADD | SUB | MULT | DIV | MOD ) expr
expr_primitive
         ::= LPAREN expr RPAREN
           | ( COMPLEMENT | NOT ) expr
           | expr_call
           | expr_call_thread
           | expr_call_childthread
           | expr_function
           | expr_add_array
           | expr_array
           | expr_field
           | expr_size
           | thisthread
           | empty_array
           | undefined
           | game
           | self
           | anim
           | level
           | animation
           | animtree
           | name
           | istring
           | string
           | vector
           | neg_float
           | neg_integer
           | float
           | integer
           | false
           | true
expr_call
         ::= object? ( expr_call_function | expr_call_pointer )
expr_call_thread
         ::= object? THREAD ( expr_call_function | expr_call_pointer )
expr_call_childthread
         ::= object? CHILDTHREAD ( expr_call_function | expr_call_pointer )
expr_call_function
         ::= ( file DOUBLECOLON )? name LPAREN expr_arguments RPAREN
expr_call_pointer
         ::= CALL? LBRACKET LBRACKET expr RBRACKET RBRACKET LPAREN expr_arguments RPAREN
expr_arguments
         ::= expr_arguments_filled
           | expr_arguments_empty
expr_arguments_filled
         ::= ( expr_arguments COMMA )? expr
expr_arguments_empty
         ::=
expr_function
         ::= file? DOUBLECOLON name
expr_add_array
         ::= LBRACKET expr_arguments_filled RBRACKET
expr_array
         ::= object LBRACKET expr RBRACKET
expr_field
         ::= object DOT name
expr_size
         ::= object SIZE
object   ::= expr_call
           | expr_array
           | expr_field
           | game
           | self
           | anim
           | level
           | name
thisthread
         ::= THISTHREAD
empty_array
         ::= LBRACKET RBRACKET
undefined
         ::= UNDEFINED
game     ::= GAME
self     ::= SELF
anim     ::= ANIM
level    ::= LEVEL
animation
         ::= MOD NAME
animtree ::= ANIMTREE
name     ::= NAME
file     ::= FILE
istring  ::= ISTRING
string   ::= STRING
vector   ::= LPAREN expr COMMA expr COMMA expr RPAREN
neg_float
         ::= SUB FLOAT
neg_integer
         ::= SUB INTEGER
float    ::= FLOAT
integer  ::= INTEGER
false    ::= FALSE
true     ::= TRUE

// Tokens from https://github.com/xensik/gsc-tool/blob/3d94bb6fb9d6169fbe19f047e94859317fd008fa/gen/h1/lexer.lpp

BREAKPOINT ::= "breakpoint"
PROFBEGIN ::= "prof_begin"
PROFEND ::= "prof_end"
INCLUDE ::= "#include"
USINGTREE ::= "#using_animtree"
ANIMTREE ::= "#animtree"
ENDON ::= "endon"
NOTIFY ::= "notify"
WAIT ::= "wait"
WAITTILL ::= "waittill"
WAITTILLMATCH ::= "waittillmatch"
WAITTILLFRAMEEND ::= "waittillframeend"
WAITFRAME ::= "waitframe"
IF ::= "if"
ELSE ::= "else"
WHILE ::= "while"
FOR ::= "for"
FOREACH ::= "foreach"
IN ::= "in"
SWITCH ::= "switch"
CASE ::= "case"
DEFAULT ::= "default"
BREAK ::= "break"
CONTINUE ::= "continue"
RETURN ::= "return"
THREAD ::= "thread"
CHILDTHREAD ::= "childthread"
THISTHREAD ::= "thisthread"
CALL ::= "call"
TRUE ::= "true"
FALSE ::= "false"
UNDEFINED ::= "undefined"
SIZE ::= ".size"
GAME ::= "game"
SELF ::= "self"
ANIM ::= "anim"
LEVEL ::= "level"
LPAREN ::= "("
RPAREN ::= ")"
LBRACE ::= "{"
RBRACE ::= "}"
LBRACKET ::= "["
RBRACKET ::= "]"
COMMA ::= ","
DOT ::= "."
DOUBLECOLON ::= "::"
COLON ::= ":"
SEMICOLON ::= ";"
INCREMENT ::= "++"
DECREMENT ::= "--"
ASSIGN_LSHIFT ::= "<<="
ASSIGN_RSHIFT ::= ">>="
LSHIFT ::= "<<"
RSHIFT ::= ">>"
OR ::= "||"
AND ::= "&&"
EQUALITY ::= "=="
INEQUALITY ::= "!="
LESS_EQUAL ::= "<="
GREATER_EQUAL ::= ">="
LESS ::= "<"
GREATER ::= ">"
ASSIGN_ADD ::= "+="
ASSIGN_SUB ::= "-="
ASSIGN_MULT ::= "*="
ASSIGN_DIV ::= "/="
ASSIGN_MOD ::= "%="
ASSIGN_BITWISE_OR ::= "|="
ASSIGN_BITWISE_AND ::= "&="
ASSIGN_BITWISE_EXOR ::= "^="
ASSIGN ::= "="
ADD ::= "+"
SUB ::= "-"
MULT ::= "*"
DIV ::= "/"
MOD ::= "%"
NOT ::= "!"
COMPLEMENT ::= "~"
BITWISE_OR ::= "|"
BITWISE_AND ::= "&"
BITWISE_EXOR ::= "^"

[preprocessor]: Surrounding #inline under other macros will brick the tool

#define TOOL

#if defined(TOOL)
#inline scripts\mp\_utility;
#else
// empty
#endif

Unexpected behaviour:
Com_ERROR: [ERROR]:preprocessor:scripts/mp/_utility.gsh:136:1: missing #endif

Expected behaviour:
Compilation succeeds

Using https://git.alterware.dev/AlterWare/jump-gsc/src/branch/main/iw5/scripts/mp/_utility.gsh

Note!!!
There is nothing wrong with the header when used on Plutonium IW5
https://git.alterware.dev/AlterWare/jump-gsc/src/branch/main/iw5/scripts/mp/_jump.gsc#L7
Here there is a single #inline and there are no issues

[preprocessor]: Unable to work with methods

#define METHOD_TEST( ent ) \
    if ( ent isHost() ) \
    { \
        continue; \
    }

main()
{
    thread onPlayerConnect();
}

onPlayerConnect()
{
    while ( true )
    {
        level waittill( "connected", player );

        METHOD_TEST( player );
    }
}

Expected behaviour:
Compilation succeeds because ent isHost() is a GSC method and should be replaced correctly when the macro expands

Unexpected behaviour:

 .\gsc-tool.exe -m comp -g iw5 -s pc .\a.gsc
GSC Tool 1.4.3.297-prod created by xensik
[ERROR]:compiler:./a.gsc:2:14: missing ';' ? at ./a.gsc

Manually fixed version which proves something is wrong with the preprocessor

main()
{
    thread onPlayerConnect();
}

onPlayerConnect()
{
    while ( true )
    {
        level waittill( "connected", player );

        if ( player isHost() )
        {
            continue;
        }
    }
}
.\gsc-tool.exe -m comp -g iw5 -s pc .\a.gsc
GSC Tool 1.4.3.297-prod created by xensik
compiled iw5/a.gscbin

iw8 .gscbin decomp error

trying to decomp any iw8 .gscbin always sends the same error: script file deserialize error at "(script path)"

iw8 .gscbin files: github.com/hc20k/iw8-rawfiles

Can't build for Linux on Pop! OS

Hello, i want to use the gsc-tool on linux, so i've downloaded the git repository and execute the prebuild-linux.sh, and when i try to build the project on linux using make(Pop! OS), i have this error :

strafe@pop-os:~/Documents/Dev/cpp/gsc-tool/build$ make
==== Building xsk-utils (debug_x86) ====
==== Building xsk-gsc (debug_x86) ====
assembler.cpp
In file included from ../src/gsc/misc/types.hpp:11,
from ../src/gsc/assembler.hpp:8,
from ../src/gsc/assembler.cpp:7:
../src/gsc/misc/assembly.hpp:229:12: error: declaration of ‘xsk::gsc::opcode xsk::gsc::instruction::opcode’ changes meaning of ‘opcode’ [-fpermissive]
229 | opcode opcode;
| ^~~~~~
../src/gsc/misc/assembly.hpp:13:12: note: ‘opcode’ declared here as ‘enum class xsk::gsc::opcode’
13 | enum class opcode : u8
| ^~~~~~
In file included from ../src/gsc/assembler.cpp:8:
../src/gsc/context.hpp:25:10: error: declaration of ‘xsk::gsc::props xsk::gsc::context::props() const’ changes meaning of ‘props’ [-fpermissive]
25 | auto props() const -> props { return props_; }
| ^~~~~
In file included from ../src/gsc/assembler.hpp:8,
from ../src/gsc/assembler.cpp:7:
../src/gsc/misc/types.hpp:63:8: note: ‘props’ declared here as ‘struct xsk::gsc::props’
63 | struct props
| ^~~~~
make[1]: *** [xsk-gsc.make:181 : obj/debug/xsk-gsc/x86/assembler.o] Erreur 1
make: *** [Makefile:134 : xsk-gsc] Erreur 2

[BUG] [T6] A problem with setting struct elements

I've encountered a problem with recent releases related to structs. Directly updating struct elements seems to no longer be possible, unless it's done via self. (just the very presence of self. in front of the line helps, as you can see with the examples below). Problem is present on versions 1.1.0 and 1.0.688

I will mention that examples of the code that no longer work, do work just fine with version 1.0.540 as well as old compiler. Examples are difectly from my code base. I tried to provide just the relevant parts to keep it compact, but if more details are needed i can also do that

Example 1:

    watermark = createserverfontstring("hudsmall" , 1.2);
    watermark setPoint("CENTER", "TOP", x_pos, -5);
    watermark.color = color;
    watermark setText(text);
    watermark.alpha = alpha_override;
    watermark.hidewheninmenu = 0;

does not update eiter color or alpha, but as soon as the update is abstracted to a separate function, it works just fine

    watermark = createserverfontstring("hudsmall" , 1.2);
    watermark setPoint("CENTER", "TOP", x_pos, -5);
    watermark set_hud_color(color);
    // watermark.color = color;
    watermark setText(text);
    watermark set_hud_alpha(alpha_override);
    // watermark.alpha = alpha_override;
    watermark.hidewheninmenu = 0;

set_hud_color(new_color)
{
    self.color = new_color;
}

set_hud_alpha(new_alpha)
{
    self.alpha = new_alpha;
}

Example 2:

        self.hud_velocity = createfontstring("default" , 1.1);
	self.hud_velocity set_hud_properties("hud_velocity", "CENTER", "CENTER", "CENTER", 200);
	self.hud_velocity.alpha = 0.75;
	self.hud_velocity.hidewheninmenu = 1;

    while (true)
    {
        self velocity_visible(self.hud_velocity);

	velocity = int(length(self getvelocity() * (1, 1, 0)));
	self.hud_velocity velocity_meter_scale(velocity);
        self.hud_velocity setValue(velocity);

        wait 0.05;
    }

velocity_visible(hud)
{
    if (is_true(self.afterlife) || getDvar("velocity") == "0")
        hud.alpha = 0;
    else
        hud.alpha = 1;
}

Leaves alpha element permanently at 0.75, but changing it into something like that:

        self.hud_velocity = createfontstring("default" , 1.1);
	self.hud_velocity set_hud_properties("hud_velocity", "CENTER", "CENTER", "CENTER", 200);
	self.hud_velocity.alpha = 0.75;
	self.hud_velocity.hidewheninmenu = 1;

    while (true)
    {
        self.hud_velocity.alpha = self velocity_visible();

	velocity = int(length(self getvelocity() * (1, 1, 0)));
	self.hud_velocity velocity_meter_scale(velocity);
        self.hud_velocity setValue(velocity);

        wait 0.05;
    }
}

velocity_visible(default_alpha)
{
    if (!isDefined(default_alpha))
        default_alpha = 0.75;

    if (is_true(self.afterlife) || getDvar("velocity") == "0")
        return 0;
    return default_alpha;
}

Performs the update just fine. The 2nd example does it completely the opposite way of the first one, but still the only way it works is to update the element via self.

[preprocessor]: Unreachable blocks still processed for some macros

#define TEST

#ifndef TEST
#error How did this happen
#endif

main()
{
}

Expected behaviour:

#error block should not be processed at all even though it's technically unsupported because ifndef TEST should never trigger because we defined TEST two lines before.

This is the case for C++ compilers

image

Unexpected behaviour:

.\gsc-tool.exe -m comp -g iw5 -s pc .\a.gsc
GSC Tool 1.4.3.297-prod created by xensik
[ERROR]:preprocessor:./a.gsc:4:2: #error directive not supported at ./a.gsc

[BUG] [T6] Most vectors cause server to hang when used as an argument in a function

The issue occurs when using release 1.0.347 25f20d8 (or previous), to compile a t6 script.

When running the script below, in a plutonium t6 zm server, the server will hang, similar to if it is in an infinite loop.
Execution halts immediately after a function with a vector as an argument is called 3 times.

Problem does not occur if vector contains only the values -1, 0, 0.0, or 1 in each place.

I have not tested to see if this affects scripts loaded on the t6 zm client, or t6 mp.

Example script to reproduce issue:

#include common_scripts\utility;
#include maps\mp\zombies\_zm_utility;

init()
{
	onplayerconnect_callback(::onPlayerConnect_test);
}


onPlayerConnect_test()
{
	level endon( "end_game" );
	self endon( "disconnect" );
	self thread vector_test();
}

test_function_2(vector)
{
	iprintln("test_function_2 called");
	//iprintln("vector: " + vector);
}

vector_test()
{
	level endon( "end_game" );
	self endon("disconnect");

	while(1)
	{
		if(self useButtonPressed())
		{


			vector = (60,0,0); //if any of these values are anything other than -1, 0, 1, or, 0.0 the server will hang on the third time the function with a vector as an argument is called.

            
			//self scripts\zm\crash_test::test_function_2(vector); //crash
			//self test_function_2(vector); //crash
			//scripts\zm\crash_test::test_function_2(vector); //crash
			//self scripts\zm\crash_test::test_function_2((1,0,.2)); //crash
			//test_function_2(vector); // crash
			iprintln("vector: " + vector); //crash
		}
		wait 0.1;
	}
}

ww2 .gscbin decomp error

./gsc-tool.exe -m decomp -g S2 -s pc D:\cod_modding\asztal\gsc_pack\ww2\scripts\896.gscbin
GSC Tool 1.4.2.291 created by xensik
[ERROR]: couldn't resolve opcode enum for '10' at D:/cod_modding/asztal/gsc_pack/ww2/scripts/896.gscbin

Warzone pacific update breaks decompilation of various scripts

After the December update to MW/ Warzone a lot of scripts fail to decompile. Just to give examples of some scripts that are throwing errors:

16.gsc -> Couldn't resolve instruction size for 194
1824.gsc -> [gsc decompiler]: LOCATION NOT FOUND! (loc_1DF)
1866.gsc -> Couldn't resolve instruction size for 198
1912.gsc -> Couldn't resolve instruction size for 175
1914.gsc -> [gsc]: Couldn't resolve builtin function name for id '44512'!
1918.gsc -> WARNING: bad local var access
1923.gsc -> [gsc]: Couldn't resolve builtin function name for id '1086'!

[BUG] [PREPROCESSOR] Logic errors

Hi,

I noticed the 2 following bugs in the preprocessor:

  • #elifdef runs even if the previous #ifdef was true.
#define A
#define B
init()
{
#ifdef A
    println("A");
#elifdef B
    println("B");
#else
    println("else");
#endif
}

Expected output:

init()
{
    println( "A" );
}

Actual output:

init()
{
    println( "A" );
    println( "B" );
}
  • #elifdef makes the #else run even if the previous first #ifdef was true (the #else doesn't run when it's just a #ifdef without a #elifdef).
#define A
init()
{
#ifdef A
    println("A");
#elifdef B
    println("B");
#else
    println("else");
#endif
}

Expected output:

init()
{
    println( "A" );
}

Actual output:

init()
{
    println( "A" );
    println( "else" );
}

I tried to dig through the code to find where the problem could come from, to no avail, sorry...

Adding an actual preprocessor to GSC is one of the coolest things about this project in my opinion, so I hope this bug report can make it even better!

[BUG] [T6] Issue detecting missing ";"

Using the latest release there is a bug in the compiler functionality when compiling T6 scripts where some missing ';' are not detected by it. Therefore it allows you to compile syntactically incorrect scripts causing the game to throw and execution error later.

Example working expectedly:

// file path: "src/t6/test.gsc"

init()
{
    println("foo1");
    println("foo2")
}
./bin/gsc-tool.exe comp t6 src/t6/test.gsc
[ERROR]:compiler:src/t6/test.gsc:5:1: syntax error, unexpected } at src/t6/test.gsc

Example working unexpectedly:

// file path: "src/t6/test.gsc"

init()
{
    println("foo1")
    println("foo2");
}
./bin/gsc-tool.exe comp t6 src/t6/test.gsc
compiled t6/test.gsc

Game error:
game-error

Console error:
console-error

decompile problem

Hey, is there a reason that you cant decompile iw5(pc) zonetool .cgsc files?

If i try too use "gsc-tool decomp iw5 ally_so_delta.cgsc" i get this "error" - "expected .gscbin file at ally_so_delta.cgsc"

add names iw6

hi
maybe check this for iw6 correct and add name
_id_6B55,script_bombmode_original
_id_6CCF,script_targetoffset_z , this maybe ok
_id_6B19,script_accel
_id_6B24,script_airspeed
_id_4FB0,ltorigin
_id_6109,precache_script
_id_7703,sound_csv_include
_id_4E11,lighttargetname

[Bug]Issues with nested folders

Using latest commit ( ac2b8a6 ) on dev branch, and using debug build from source.
(but also happens with latest release)

When feeding gsc-tool a path that contains nested folders, it handles them in unexpected ways.

(for this, i am using the scripts extracted from t6's zm_tomb_patch.ff)

compiled_scripts_dir.txt

For example, when using this command:
C:\Users\scott\source\bo2 resources\gsc-tool>.\gsc-tool.exe decomp t6 "C:\Users\scott\source\bo2 resources\gsc-tool\maps " > output.txt 2>&1
output.txt

If you have say, /maps/mp/(gsc files) with maps only containing the mp folder, the decompiled folder will contain \t6\maps\mp

with mp being a file, with no extension, and contains the decompiled script for the last file in the folder, alphabetically, i assume?

It essentially skips all scripts aside from the last one found, and names it the nested folder name.
//

Another example.
Say you remove the maps folder. you end up with nested folders like \mp\animscripts\traverse\, but this time, the mp folder has other files and folders in the same directory as the nested folder.
and like the last one, animscripts is empty aside from the traverse folder.

The behavior is a bit different in this situation.

C:\Users\scott\source\bo2 resources\gsc-tool>.\gsc-tool.exe decomp t6 "C:\Users\scott\source\bo2 resources\gsc-tool\mp" > output_2.txt 2>&1

output_2.txt

In this case, you end up with the file\decompiled\t6\animscripts\traverse , with it containing the script for the last file in the \mp\animscripts\traverse\ folder. but in this case, all other folders and files in the specified path will be decompiled in place, rather than keeping the original files, and putting the decompiled scripts in the decompiled folder.

I haven't done any other testing than this. (haven't checked other modes, files, or folders, or what happens if gsc-tool is in a different filepath or drive from the compiled scripts)

issue with gsc tool iw7

Every time I open the premake5 it does not open or opens for a second anyways I know this is probably a easy fix someone tell me how to fix it please.

feature request

Is it possible too de/compile multiple files, if not could we may add that as a feature?

Why? Well it would make life easier, you wouldn't waste that much time too decompile every single file.

For example,
$gsc-tool.exe iw5 decomp "PATH-TO-FOLDER-NAME" -> "C:\gscdump" <- put ".gscbin" files for de/compile in there.

[Help] Can't Install WWII

If I were to fix my issue with installing WWII, would this tool allow me to basically SDK dump the S2 engine or? I just want a general understanding of how it works cause I'm new to this. Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.