id Tech Forums

id Tech 4 (Doom3/Prey/Q4) => id Tech 4 Engine Coding => Topic started by: bitterman on October 04, 2015, 10:40:04 AM

Title: SWF problems
Post by: bitterman on October 04, 2015, 10:40:04 AM
Spent a lot of time with try to change engine from D3 to D3BFG.

The main reason was the possibility of using glsl in D3BFG (unlike ARB shaders in D3).

But there are a few ground problems.

First it's a new GUI system based on SWF.

As I suggest guys from ID make a own swf-parser based on ActionScript 2.0 and commandset swf version 7. Moreover the engine convert swf into bswf and then run it with code.

All menus found in base/generated/swf. A main menu (shell.bswf) contain a one main sprite (MovieClip) and ~20 sub-sprites placed in certain sequence. Every sprite action (event) is hardcoded and handled with own proc (HandleAction). Transition between sprites (menu screens) is also hardcoded via SetNextScreen().

In D3BFG a game start with simple "map game/mars_city1" after exec ShowDoomIntro().

There are a few CVARs for swf (swf_loadBinary, swf_debug).

The next shell.swf (Flashdevelop AS2, 1280x960) is compiled and exec in Flash but not working as well in Game:

class Main
{

public static function main(swfRoot:MovieClip):Void
{
// entry point

var menuScreens : Array = new Array(
"NULL",
"menuRoot",
"menuCampaign",
"menuSettings",
"menuLoad",
"menuNewGame",
"menuSystemOptions",
"menuGameOptions",
"menuPartyLobby",
"menuGameLobby",
"menuStereo",
"menuDifficulty",
"menuControls",
"menuKeyboard",
"menuResolution",
"menuController",
"menuDev",
"menuLeaderboards",
"menuGamepad",
"menuMatch",
"menuModeSelect",
"menuBrowser",
"menuCredits");

var myClip : MovieClip = new MovieClip;

myClip = _root.createEmptyMovieClip("menuStart", 0);

for (var i = 1; i < 23; i++) {
// trace( menuScreens[i] );
myClip.attachMovie( menuScreens[i], menuScreens[i], i);
}
}
public function Main()
{

}


And there is no original shell.as or a manual like iddevnet.

Have anyone an idea how to proceed reverse-engineering this process?

Is it possible to ask the developer of the code listing for shell.bswf (e.g. for education/modding purposes)?
How to make it correct?





Title: Re: SWF problems
Post by: bitterman on October 05, 2015, 10:14:55 PM
How to place custom shell.swf as a mod to debug it in MSVC?

Ok, now I'm trying to add custom console command:


CONSOLE_COMMAND(swfToBswf, "Convert SWF to BSWF", NULL) {

idStr fileName = args.Argv(1);

if ( LoadSWF(filename) ) {
fileName.SetFileExtension(".bwsf");

if (!WriteBinary(fileName)){
idLib::Printf("BSWF write error");
}

idLib::Printf("SWF to BSWF converted");
}
else {
idLib::Printf("Can't load SWF");
}

}


But it gives an unexpected errors:

4 IntelliSense: this operator is not allowed in a constant expression d:\DOOM-3-BFG-master\neo\idlib\geometry\DrawVert.h 182 1 Doom3BFG
5 IntelliSense: this operator is not allowed in a constant expression d:\DOOM-3-BFG-master\neo\idlib\geometry\DrawVert.h 183 1 Doom3BFG
6 IntelliSense: this operator is not allowed in a constant expression d:\DOOM-3-BFG-master\neo\idlib\geometry\DrawVert.h 184 1 Doom3BFG
7 IntelliSense: this operator is not allowed in a constant expression d:\DOOM-3-BFG-master\neo\idlib\geometry\DrawVert.h 719 1 Doom3BFG
8 IntelliSense: this operator is not allowed in a constant expression d:\DOOM-3-BFG-master\neo\idlib\geometry\DrawVert.h 745 1 Doom3BFG
9 IntelliSense: this operator is not allowed in a constant expression d:\DOOM-3-BFG-master\neo\idlib\geometry\DrawVert.h 746 1 Doom3BFG
10 IntelliSense: this operator is not allowed in a constant expression d:\DOOM-3-BFG-master\neo\idlib\geometry\DrawVert.h 747 1 Doom3BFG
11 IntelliSense: this operator is not allowed in a constant expression d:\DOOM-3-BFG-master\neo\idlib\geometry\JointTransform.h 58 1 Doom3BFG
12 IntelliSense: this operator is not allowed in a constant expression d:\DOOM-3-BFG-master\neo\idlib\geometry\JointTransform.h 59 1 Doom3BFG
13 IntelliSense: enumeration value is out of 'int' range d:\DOOM-3-BFG-master\neo\renderer\Material.h 290 26 Doom3BFG
14 IntelliSense: PCH warning: cannot find a suitable header stop location.  An IntelliSense PCH file was not generated. d:\DOOM-3-BFG-master\neo\swf\SWF_Main.cpp 32 16 Doom3BFG
15 IntelliSense: identifier "LoadSWF" is undefined d:\DOOM-3-BFG-master\neo\swf\SWF_Main.cpp 715 6 Doom3BFG
16 IntelliSense: identifier "filename" is undefined d:\DOOM-3-BFG-master\neo\swf\SWF_Main.cpp 715 14 Doom3BFG
17 IntelliSense: identifier "WriteBinary" is undefined d:\DOOM-3-BFG-master\neo\swf\SWF_Main.cpp 718 7 Doom3BFG


Why this code not work?
Title: Re: SWF problems
Post by: bitterman on October 08, 2015, 11:47:26 AM
Ok, filename -> fileName.

But why these native funsc (LoadSWF, WriteBinary) are "undefined"?
Title: Re: SWF problems
Post by: motorsep on October 08, 2015, 12:17:43 PM
I think it would be more beneficial to port back original fullscreen GUI system so that RBDoom 3 BFG could use original Doom 3 menus and such.

That would ensure menus can be modified on Linux / Mac by modders.

The only thing you'd want to improve is support for widescreen and gamepad. Since gamepad works with in-game GUIs, it shouldn't be hard to make it work with full screen GUIs.
Title: Re: SWF problems
Post by: bitterman on October 09, 2015, 03:41:55 AM
Then I vote for the revision of the original D3 engine only with ARB -> GLSL (binary resources are also not a sugar).

What kind of lamp I have to rub? :)

No kidding, how to add console command in my case?

***********

Ok, this is also wrong

if (!WriteBinary(fileName))

because:

void       WriteBinary( const char * bfilename );
Title: Re: SWF problems
Post by: bitterman on October 09, 2015, 11:31:39 PM
Ок, looks like the problem with class and consrtuctor:

class idSWF {
public:
...
private:
   friend class idSWFSprite;
   friend class idSWFSpriteInstance;

   bool       LoadSWF( const char * fullpath );
   void       WriteBinary( const char * bfilename );


So I can't use just "LoadSWF()" anywhere where I want.

Some like:

idSWF LoadSWF(filename)

This example was compiled but worked incorrect.

But I see a great potential of CONSOLE_COMMAND.

Perhaps this is much easier than creating an separate tools.
Title: Re: SWF problems
Post by: motorsep on October 10, 2015, 09:30:20 AM
Quote from: bitterman on October 09, 2015, 03:41:55 AM
Then I vote for the revision of the original D3 engine only with ARB -> GLSL (binary resources are also not a sugar).

What kind of lamp I have to rub? :)

No kidding, old menu rendering code and parsing is in the engine. You'd basically disable entire SWF menu code and bring back old menu code.

Title: Re: SWF problems
Post by: bitterman on October 11, 2015, 09:40:59 PM
Well, it's sounds too hard for me.

By the way, code can be inserted directly into loadBinary().

After that my custom .swf (2 Kb) was converted to bswf (114 Kb).

Very nice 8)

But as I think all this movements are hopeless without original .swf (.actionscript) source code.
Guys, do you know who wrote it?
May be few tips from that guy...

P.S. Hey, motorsep, your remarks make me move, but where? :))))
Title: Re: SWF problems
Post by: motorsep on October 12, 2015, 11:45:27 PM
Quote from: bitterman on October 11, 2015, 09:40:59 PM
P.S. Hey, motorsep, your remarks make me move, but where? :))))

Like, move to another engine? That would be a wise move :)
Title: Re: SWF problems
Post by: bitterman on October 20, 2015, 11:43:56 PM
http://idtechforums.fuzzylogicinc.com/index.php?topic=280.msg3340#msg3340 (http://idtechforums.fuzzylogicinc.com/index.php?topic=280.msg3340#msg3340)

Thanks trebor looked at the structure of the shell.bswf (and dialog.bswf).

As I think it's working with frames and a little actionscript.

Looks like the menu is mostly based on the timeline and only use opensource FlashDevelop will not work (as I tried above).

Remains trial version of Flash Professional. Not sure about this.

And hard-coded transitions (from one screen to other) are still the problem.
Title: Re: SWF problems
Post by: bitterman on June 21, 2016, 09:51:08 PM
Very simple hud

P.S. Still not clear about registration/transformation point for movie clip (sprite) in Flash.
Must it always be set to upper left corner?
Title: Re: SWF problems
Post by: motorsep on June 22, 2016, 08:06:43 AM
Lol dude. You have SWF file with working full screen interface and you can't understand how it works?! That's something else  :(
Title: Re: SWF problems
Post by: bitterman on June 22, 2016, 10:12:19 PM
When I play with regpoint then my nested sprite start to wander on screen.

But in your words hidden wisdom I feel that now you kindly explain ))
Title: Re: SWF problems
Post by: motorsep on June 23, 2016, 08:06:43 AM
Not sure what you mean by reg point. If you mean anchor point, then it doesn't matter where it is. My SWF files are already setup to work with existing BFG's code. Just look at the layout and follow the trend.
Title: Re: SWF problems
Post by: bitterman on June 23, 2016, 10:13:39 PM
Your's .fla files are good but as I said earlier they needs a tutorial.

Like a tutorial about change native doom3 gui to doom1 gui (remember doom3wolrd).

Too many complex stuff and interactions.

But yes, files are good ))
Title: Re: SWF problems
Post by: motorsep on June 23, 2016, 10:37:19 PM
Quote from: bitterman on June 23, 2016, 10:13:39 PM
Your's .fla files are good but as I said earlier they needs a tutorial.

Like a tutorial about change native doom3 gui to doom1 gui (remember doom3wolrd).

Too many complex stuff and interactions.

But yes, files are good ))

You can't really do that without rewriting C++ code.

SWF files are basically just graphics and layout. How they interact, when and in what order they animate is driven by C++ entirely. RAGE had most of the stuff in ActionScript. Doom 4 (and the DOOM) evolved into having virtually no ActionScript. Doom 3 BFG's SWF menu system is almost identical to Doom 4, except dialog windows, that are identical to RAGE (AS driven instead of C++).

I don't know the state of ActionScript, but I do know that Flash is no more. Now it's Adobe Animate, which supports SWF, but perhaps doesn't have the same ActionScript Flash had. So in a way it was a good move to get off Action Script in Doom/BFG to avoid incompatibilities in the future.
Title: Re: SWF problems
Post by: bitterman on June 24, 2016, 12:00:09 AM
Thanks, it's interesting.

I'd like to know is it possible to provide in new HUD information about AI states, world positions and other (without coding).

Just like D3 with script and EditGUIs only:

Title: Re: SWF problems
Post by: motorsep on June 24, 2016, 08:19:42 AM
You'd need to add new elements to SWF in Flash, following the same scheme as other HUD elements, then write supporting code in C++.
Title: Re: SWF problems
Post by: bitterman on July 01, 2016, 06:29:58 AM
I have one question about swf decompile (JPEXS).

When I do this I see that one sprite (movie clip) have (associated) few files with ActionScript code (see picture).

Usually one sprite on scene have one layer named "actions" or "as" and then it must be associated with one AS file.

Is it few files means one sprite with few layers of as-code? In what cases is it necessary?

Thanks.

P.S. motorsep as I see you change AS-code from dialog.swf.
Can you give few tips about this file (destination, sprites organizations, AS-code, etc.)?
Title: Re: SWF problems
Post by: motorsep on July 01, 2016, 07:30:11 AM
I don't understand what's going on with you  ??? I released SWF files so that anyone can look at the code/layout and check it against C++ code. It's really that simple now. No reverse engineering is required.

Get yourself a book about Flash MX with CD and activate trial using publicly available serial number (that's what I did) or get newer version some other way. Open dialog.SWF and see how it's done. There is a layer called AS which has all the AS code.
Title: Re: SWF problems
Post by: bitterman on July 02, 2016, 11:03:52 AM
Ok, now I see:

This AS-code from original dialog.swf:

...btn.onPress = function()
{
this["func"...].call();
}


isn't works in my case.

But this code works:

...btn.onPress = function()
{
acceptCallBack();
}


But the cursor looks weird (see picture).

******************* upd ******************

Fix via extend background to fullscreen.
Title: Re: SWF problems (recordDemo issue)
Post by: bitterman on July 12, 2016, 10:51:35 PM
May be anyone know:

Can't record a demo from BFG menu (e.g. in Main Menu, not in Game) via 'recordDemo' console command.

Menus are handmade, assets are minimal (may be this is problem).

As I remember, in D3 I used 'recordDemo', then 'stopRecording', then 'aviDemo demo000.demo' to convert from .demo to .tga (but not sure about recording from menu).

Thanks.

************************** upd ******************

Hmm, looks like full BFG version recorded demo from mainmenu but not played nor converted it with this error:

QuoteidRenderWorld::RenderScene: bad FOVs: 0.000000, 0.000000

/*

void idRenderWorldLocal::RenderScene( const renderView_t *renderView ) {

...

>>> if ( renderView->fov_x <= 0 || renderView->fov_y <= 0 ) {   <<<
common->Error( "idRenderWorld::RenderScene: bad FOVs: %f, %f", renderView->fov_x, renderView->fov_y );
}


But g_fov is set to 80 by default.

Can anyone check 'recordDemo/stopRecording/playDemo/aviDemo' in BFG version, please?

Is it works? My build is a Frankenstein's creature ))
Title: Re: SWF problems
Post by: motorsep on July 13, 2016, 08:31:22 AM
Demo recording is not supported in BFG. But it's been fixed in Storm Engine 2 :)
Title: Re: SWF problems
Post by: bitterman on July 13, 2016, 11:11:56 AM
Yes, I found some info...

https://github.com/RobertBeckebans/RBDOOM-3-BFG/issues/127 (https://github.com/RobertBeckebans/RBDOOM-3-BFG/issues/127)

Not sure, it was fixed in RBDoom or still WIP?

@motorsep, still not sure about compatibility. E.g. don't see doomintro.swf in SS2 pack.
Is Code was modified to start new game without doomintro, right?
Title: Re: SWF problems
Post by: motorsep on July 13, 2016, 11:29:47 AM
I didn't include anything that I didn't need for my Phaeton game. Especially those text typing SWF files (they'd render over video).

Like I said, Storm Engine 2 is not directly compatible with Doom 3 BFG. It's was meant to be used in projects made from scratch. So, if you use SWF that come with SE2, and then figure out the rest of the assets, you can build your game using our engine.
Title: Re: SWF problems (pacifier)
Post by: bitterman on July 22, 2016, 05:02:49 AM
Because of some language barriers I realy don't understand this term ('Pacifier'), which hinders the understanding of code.

This is a movie clip (sprite) named "pacifier". If it's visible then engine (part of menus managment) makes one thing, if not - other thing. It uses some hardcoded funcs like:

IsPacifierVisible()
HidePacifier();

A 'pacifier' is a synonym of 'dummy' or 'empty' (not realy sure).

Can you tell me - what means this term (not neccesary in this Code)?

The purpose of the others variables is intuitive from their names but this... Really obscure idiomatic expression 8)
Title: Re: SWF problems
Post by: motorsep on July 22, 2016, 03:49:15 PM
Yeah, poor naming IMO. Pacifier is just an animated indicator, like hourglass. Like when saving, or connecting somewhere, it's being rendered. I couldn't get it working (the game would freeze on any SWF pacifier I made), so I abandoned it.
Title: Re: SWF problems
Post by: bitterman on July 22, 2016, 10:34:38 PM
Yes, now I see. Thanks for explanation.

If you follow my way: about recordDemo issue http://idtechforums.fuzzylogicinc.com/index.php?topic=465.msg5360#msg5360