Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > CopperCube Open discussion
Replacing external CCB files with EXE files

Registered User
2020-09-21 23:50:41

This is only for users that are (justifiably) worried about using ’ccbSwitchToCCBFile’ because their game can’t be compiled into a single exe because of the editor’s memory limitations.
…also only for those users that haven’t figured this out already :)

////////// Explanation on how I stumbled onto this solution, you can skip it…

In my new game, I had the main exe file with menu, intro, and two levels but the third level had to be externalized because the editor kept crashing. So everything was normal for CC because I was never able to successfully get more than two levels into a single work-file :)
I had a load-game option in the game’s menu, auto-save in level 2, and auto-save in level 3, so that means: load& auto-save in exe and auto-save in external ccb. When I tried to load a saved game from Level 3 I noticed that I was actually loading the saved data from Level 2 and not Level 3.

After some time I realized that my ‘Application Title’ under ‘Publishing Settings’ was named correctly in the main file but left ‘Unnamed Application’ in the external ccb file. I didn’t bother to change it because I thought that any ccb file connected through the ‘ccbSwitchToCCBFile’ code will automatically inherit the app-title from the main game-file. That’s not the case, any external ccb file that we connect to with ‘ccbSwitchToCCBFile’ will keep it’s original app-title.
My saved variables from Level 3 are not being loaded from the game’s menu because the app is treating them like saved data from another app. That means that it’s treating external ccb files as different games, which means that differently titled files are treated as different games.

After that I realized that I can have an unlimited number of exe files titled with the same name and have one saved-variables data for all of them :) And I was right: simple box level compiled with the same title as the main game was able to change my saved variables.

////////// The system of exe files instead of external ccb files

All your files (game levels) must be named exactly the same in Tools > Publishing Settings > Application Title.

In your main game file (first exe to start the game) you need to have:
1. ‘New Game’ button that will reset all of the saved data
2. ‘Load Game’ button for loading auto-saved data
3. After loading auto-saved data, instead of ‘ccbSwitchToCCBFile(“level3.ccb”);’ you need ‘system(“START level3.exe”); ccbEndProgram();’ that will start level3.exe and close currently opened exe file.

In all of the following levels compiled to exe you need to have:
1. Loading of auto-saved data in ‘Before First Drawing Do Something’
2. Always saving data before continuing to a different exe file.
3. ‘Go To Menu’ button with ‘system(“START main.exe”); ccbEndProgram();’ instead of ‘ccbSwitchToScene(“menu”);’

This way you can have (reasonably) protected levels (compiled into exe files) instead of multiple ccb files that can be easily opened and edited.

The same system is also possible with an external txt file for saving data or some other method, it doesn’t have to be CC’s native ‘Load Or Store Variable From Or To Disk’. The reason why I’m using native Load/Save actions is that my game has some specific systems that are preventing me from having a txt file in the game-folder and I’m too lazy for messing with C:/Users/XYZ/Documents absolute/relative paths :)

Hopefully this will be helpful to someone. Cheers!

2020-09-22 06:36:33

brilliant work 'srfstudio'. I also have been concerned for some time about all the ccb files can easily be edited by anyone. Have done some nice 'tricks' to prevent hacking but its not 100%.
Any ccb file run directly will close down due to not finding a certain variable only loaded through the initial exe file and a few others tricks but yeah not 100%.

I actually tried this method to get multiple exe files some time ago yet realised each exe file would stay open so multiple files open at the same time. You show that you can just close each exe file off after starting the load of the next one - cool !, didnt think of that...

I save to txt file all of my game info, not using the built in save function of Coppercube - and seeing your post am happy I did it that way now due to the conflicts you mentioned. I think I'm am using like 300-400 variables atm, maybe your better off using arrays and save to txt (.dat) or better (.bin - not easily editable). You don't need to worry about where installed so long as you got the correct folders from where the exe is located ...

So the molebox - virtubox thing didnt work out ?
I was looking into that...never fully tested it..

can you change the .exe to look better like anything you want like .lvl or something or do all the files have to end in .exe ?

2020-09-22 12:02:31

I just checked the above situation and true enough - ALL variables in memory are lost when you exit out of the initial exe file to load the next one.

Also you can change the file type 'exe' to whatever you want to look better like '.lvl' or whatever. You can also change the directory to be inside a folder as you like using this format:

system("START data/levels/Nu3.lvl");
(means I have a folder "levels' under a folder 'data')

The only thing I don't like for now is the screen minimize animation I get in Windows 7 every time you end the previous exe file...

Registered User
2020-09-22 13:39:34

I’ve been very uncomfortable with having ccb files next to my game build, also made similar things like you, with renaming ccb files or inserting variables that prevent hacking. I was never really happy with it since any protection must be done through the code in a ccb file, if a file can be easily opened code can be modified or commented-out :)
I realize that there’s no way to make things safe, anything can be cracked, I was just not happy that my game can be cracked with a simple search, rename, open & comment-out :D

You probably tried it but my biggest shock, from about a year ago, was when I accidentally removed some scripts from CC extension folder. I was searching around to see if I have some copies of the scripts somewhere else and then realized that they magically appeared back in the extension folder. I made a test by deleting everything from the extension folder: by opening any ccb file all my scripts from that file were back (re-created) in the extension folder.
So leaving ccb files didn’t just mean access to functional levels, it meant everything: geometry, models, scripts, sounds, music…
The only thing that I’m not sure about are animated models, I never really checked if they can be exported.

Yeah, 400 variables would be complete chaos if done through native load/save actions :D I have around 80 variables for saving in my Aziella Chronicles game and I use txt file but in this new game, I have only 12. It’s more or less a simple fps shooter and not many variables are needed so I wanted to try CC’s save system for the desktop version. But for anything other than a simple fps native system would be almost unusable.

I’ve tried Molebox but it was messy and the antivirus software was false-reporting some very severe viruses. It’s bad enough if there is some false positive reporting of some small things but false-positive reports of severe viruses were not acceptable. People will immediately delete the game and never look back, I know I would :)

It’s great that exe can be renamed into something else, never tried it, cheers! The game folder was looking kind of weird with multiple exe files next to each other :)

Relative paths are o.k. but my problem is that all my game files are being re-created/extracted every time the game is to be played. That means my save-file must be outside, in a neutral location. For Aziella I used Construct 2 as a starter and had a dialog box that allows users to choose where to place some extra files. For this game that seems to be overkill since there are only 12 variables :)

2020-09-22 15:31:03

very nice - I just worked out you can stop the windows minimize animations in the settings on close so its actually very usable and I think I will re code all my levels to suit now - cheers !

Strangely the levels load up about 25% quicker this way also I noticed !

I had a few extra tricks up my sleeve to stop hacking that I wouldn't not post here in the forum but contact me here and will send you the file example - you will like what I came up with...

cheers !

2020-09-22 15:41:53

I don't have any load custom images and it loads up very quick - only a small flash on exit/load next exe but that's ok for what you get - all your data protected - cool! , its been a big concern for me too with tonnes and tonnes of quality coding that anyone could just change some things and sell a copy of my game as their own...very uncool.

I nonetheless had all my array data on load in the start exe only so would take a genius to rebuild what was not working to get my game hacked and redone...I even had the location and file type of the next level to load as variables so not easily known amongst other things...still - don't have to worry now !

thanks again,
and yes, I owe you free copy when done also as agreed before.

Registered User
2020-09-24 22:54:51

Yeah, I forgot, climbing & player-hull problem, I get a free copy of Saturn 7! :D

Just a few heads-up in case you haven’t solved them already, I’ll start with the weirdest one:

1. When using system("START data/level.exe") to start a file in the ‘data’ subfolder from within the main game.exe file, Windows is treating your level.exe file as a part of the game.exe file. The location of level.exe is no longer game-folder > data-folder but its game-folder for some completely stupid reason.

If I want to restart the main game.exe from within level.exe with the system("START ../game.exe") it breaks the game on Win7 so I had to use system("START game.exe"). Both ways are functioning on Win10 however. Maybe it’s some sort of a CC thing happening only on Win7 but it is what it is.

2. When changing file extensions from exe to something else everything is o.k. on Win7 but on Win10 it’s not. Win10 opens a dialog box asking you with what program you want to run your file.

My Win7 is on an older computer and I ‘customized’ it to death :) My Win10 is almost complete vanilla since I wanted to keep everything on ‘factory settings’ as long as possible.

3. When starting exe files using system("START xyz.exe") + ccbEndProgram() the messy visuals of closing first window and starting a next one are somewhat o.k. when setting your app to: Exclusive/Fixed size + Resolution Weight & Height to 1 + Full Screen + Use Desktop Resolution + Loading Screen Text & Image to none.

This means that window-mode is more or less unusable but maybe it can still be used with changing the weight/height settings after the file has been loaded.

I just worked out you can stop the windows minimize animations in the settings on close

I never saw those options in the CC, where are they located? Are they CC default or is it a plugin/extension?

2020-09-25 03:00:17

Wow - good that you also checked Win 10 - didn't expect such discrepancies with Win 7...bit of a pain such things...

The stopping the windows minimize animations (Win 7) - I just uncheck the "animate windows while minimizing" box in Windows 7 settings: Control Panel\All Control Panel Items\System - Advanced \ Performance....

Would have to have a help menu in game to explain how to turn these off in Windows to look better....

Registered User
2020-09-25 15:07:01

Aa the CPanel... it's a good solution but it will be very difficult to get players to really change their OS settings, most of them will probably just ignore it :(
Maybe there is a cmd parameter that can be used together with close, maybe closing it without ccb code but with pure cmd would be better.

Registered User
2020-09-25 17:54:42

I can agree - most will not want to change their OS just for the sake of a single game. So I have left off some cool game features because of that....

also, I have tried to use the cmd line inside of CC, but some commands require being run as 'admin' and CC isn't able to do that. I did have a conversation with niko about it, and he said running commands as the admin would be something he would consider it some future release....

I am hoping....

Registered User
2020-09-25 18:31:33

Wait, wait, wait do you mean that system("START xyz.exe") + ccbEndProgram() won't work unless the player is using an admin account? So if the game is started, let's say, at work on a non-admin account this is not a valid approach?

If that is the case then I will have to have a small notification on the start of the game to inform the player :/

2021-07-18 16:20:23

I found a better solution which cant be hacked - the code that is. It has to do with saving your game inside an extension and having it in such a way that it cannot be extracted out again.

Contact me for more details as not for public knowledge.

2021-07-19 06:01:10

I have been using the same since a long time for accessing files, same method I use for making self destructable games. I even asked people if they wanted to know how it can be done but that thread never got any response haha😂

That's why I always say system commands are more Powerful, there are lot of other things which you can do with system commands.

There are many ways you can have to protect the game as well, you can use super extensions or global variables can also use external javascripts can encrypt the game data and decrypt it via runtime in the game.

Just like @sammhmmdy has done for his minecraft game. There are lot of possible ways to protect the game from being hacked.

Edit: @srfstudio any news about Aziella Chronicles. It's been a long since you last sent any updates regarding the game.

2021-07-20 03:33:29

Yeah system commands might work but not on all platforms.

The method I use doesnt need system commands and should work on all Windows platforms plus Mac also. Android and Web are different.

2021-07-20 07:08:21

Well, I don't know what is your method because there are many methods to achieve something in CC.

but I want to let you guys know that in order to prevent yourself from manually loading all the variables at the starting of every new file or level using some actions or behaviors.

what you can do is you can create an external javascript file with the name same as your project and can use that JS file to store all your variables and other data which you want to load in all the files.
even if you switch the file using ccbswitchfile command () the JS file data can still be accessed by all the levels or ccb files that are running unlike the extensions (behavior or actions) which also gets reloaded when you switch ccb files or levels.

there are also other methods, as I mentioned above, I am not talking about system commands specifically. I was just saying that system commands are really helpful and those commands are very underrated in the CC community. only a few people use system commands, but they are powerful enough.

hope that bit of info is useful to someone.

Create reply:

Posted by: (you are not logged in)

Enter the missing letter in: "Interna?ional" (you are not logged in)




Possible Codes

Feature Code
Link [url] [/url]
Bold [b]bold text[/b]
Image [img][/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]



Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact