Bit Blot Forum

Aquaria => Modding => Topic started by: FrancesF on April 01, 2011, 06:30:11 am

Title: New crashing thread
Post by: FrancesF on April 01, 2011, 06:30:11 am
Wow!  Re-reading old modding threads, I just came across one that made no sense to me last month, but that I now realize could explain why I've been having random crashes to my mod.

Quote
It seems that after you kill a "white square entity" (white square in the entities list, created by players), the game becomes unstable and will randomly crash after that. That could also explain some crashes players had.

You can also try this : kill the entity, and press F2 in edit mode to save, the game will crash.

If you update the entities.txt file in the Aquaria directory (scripts/entities/entities.txt) to declare an id and graphic for the entity, the problem is solved.

The only thing is I don't like modifying the game's files when installing a mod, but I guess I won't have the choice.
Yododa, 2009


Since I now have about a dozen "white square" entities, some of whom are randomly killing each other, might this be why the screen suddenly turns black and freezes? (Although the music keeps playing.)  When it happens the map is dead; there is no way to access it again either from the editor or warping from another map; the game just freezes.  The first time I lost a significant amount of work, but now I back up the map files after every session.

Does anyone have any more information on this?

Title: Re: New crashing thread
Post by: Alphasoldier on April 01, 2011, 07:45:41 am
Well you can always edit the XML files and remove the faulty entities by hand. Just search for their names.

Further than that I'd have no clue.
Title: Re: New crashing thread
Post by: FrancesF on April 01, 2011, 04:22:01 pm
I'm not sure the entities are faulty; so far they are modified from existing scripts.  Sometimes all I've changed is the graphic file and the name of the entity.  Maybe I should not save in the editor after one of them gets killed.  I had an area in the mod where Naija is trapped until she manipulates one entity into getting rid of another.  Guess I'll have to change that, or just use original entities from the game.

If I wanted to do what Yogoda suggested, and go into the entity file in the original game, how do I declare an id?
Title: Re: New crashing thread
Post by: Sindhi on April 01, 2011, 07:13:18 pm
Send a PM to Yogoda; he is done running the Minecraft server as of today, ostensibly. I get white square tiles when the names don't match (graphics vs. tilesets); don't remember what causes white square entities, but Yogoda does.
Title: Re: New crashing thread
Post by: achurch on April 02, 2011, 04:30:40 am
White squares are caused when the default entity texture isn't found, and don't by themselves cause the game to crash -- there are actually a few such cases in the original data. The "default entity texture" is the texture listed in scripts/entities/entities.txt for entities which are listed there, and the name of the entity otherwise. Thus you can avoid white squares appearing by having a texture with the entity's name in your mod's graphics directory; you don't have to actually use this graphic for the entity (and you probably won't if it's an animated sprite).

As a side note, you don't need to modify the entities.txt file to use new entities. In fact, you probably shouldn't, because then your mod wouldn't work for any players who didn't make the same changes to their own entities.txt.

If you can find a way to consistently reproduce the crash, I'd be willing to take a look and see if I can isolate the bug -- send your mod to (mynick) at (mynick) dot org.
Title: Re: New crashing thread
Post by: Sindhi on April 02, 2011, 08:26:54 am
What I know about scripting would fit in a thimble.  AChurch, please, what is a texture? I know what it is in art, but not in this context...
Title: Re: New crashing thread
Post by: achurch on April 02, 2011, 08:33:38 am
"Texture" is the term used in computer graphics to refer to a single image which is drawn on the screen, usually as part of a larger scene. Originally, the term referred specifically to images used in 3D texture mapping (that is, "wrapping" an image onto a flat surface to give the illusion of texture to the surface). These days, though, 3D libraries like OpenGL are used even for 2D graphics, as in Aquaria, so "texture" has come to mean any individual graphic used in creating a scene.

In other words, replace "texture" with "image" and it'll mean pretty much the same thing. (:
Title: Re: New crashing thread
Post by: achurch on April 02, 2011, 08:05:38 pm
It turns out the game will indeed crash if you have a custom entity (one not listed in entities.txt) which has been killed and you try to save the map. To avoid this, you'll need to either: (1) add your entities to entities.txt with unique ID numbers, with the drawback mentioned earlier that users will have to make the same changes to their own copies of entities.txt; or (2) make sure you don't save in the scene editor when there's any chance a custom entity may have been killed (this includes autosave, which can potentially strike at any time).

In theory, you could edit the map XML files to replace your custom entity IDs with entity names, to avoid the drawback associated with the entities.txt method. You'd need to parse the j="" attribute of the <Entities> tag, and replace each occurrence of your custom entity's ID (e.g. "1234") with a -1 and the entity name (e.g. "-1 MyEntity"). If you do this, be careful you don't accidentally change other entity data which just happens to have the same value as the entity ID!

Shameless self-promotion: While this requires a bit of technical knowledge, you could also compile my modified source code (http://achurch.org/cgi-bin/hg/aquaria/), to which I've just committed a fix for this bug. Unfortunately, there are incompatibilities in the script interface that prevent scripts written for the Humble Bundle (1.1.3) and earlier releases from working on the modified source code, and vice versa; see this mailing list post (http://icculus.org/pipermail/aquaria/2011-January/000317.html) for more information. Alternatively, you can build from the "custom-entity-crash-fix" branch to get just this fix and remain compatible with the original script interface.
Title: Re: New crashing thread
Post by: False.Genesis on April 03, 2011, 02:03:42 am
achurch, just out of interest:  do you think it would be a good idea to release a 1.1.4-community patch somewhere in future (based on your repo, by chance) ?
That would help many people that still have the 1.1.1 version by plimus, or those who create mods (an example here is that original game files have to be modified for certain mods to work, as you said, so giving mods more power over the game and game data would be a good thing to do -- I already have plans for that, but no time to integrate it, for now)
ofc having it compatible with existing mods is the biggest problem... something to deal with later, i guess.
Title: Re: New crashing thread
Post by: achurch on April 03, 2011, 04:49:13 am
GMMan has already built Windows binaries (http://www.bit-blot.com/forum/index.php?topic=3797.0) from both the Icculus and my repositories. I'm currently focusing on the iPad version, but when I have a chance I'll look into adding Mac and Linux binaries as well.

Due to the extent of changes to the script engine, I don't know whether it'll be possible to maintain bidirectional compatibility, though there may be a way to get scripts from 1.1.3 and earlier to work with the new binary. I'll give it some thought.
Title: Re: New crashing thread
Post by: False.Genesis on April 03, 2011, 05:01:47 pm
ofc a compatibiliy mode would be nice, but that would probably require individual tuning for each script file, in case mods with old scripts load new scripts shipped with the game.

imho a better solution (although a pain in the ass) would be to convert existing scripts for mods  (there aren't many mods anyways).
when i have some time this summer (july) i could have a go at this, so this issue can be resolved once and for all without too many compatibility problems. not that i know much about lua by now, but its just another programming language, easy to learn basics in a day, and advanced things within 3 :)

I can also build bins for 32 and 64 bit linux, and 32 bit windows (visual studio - in my fork (https://github.com/fgenesis/Aquaria) on github i finetune things especially for MSVC, but keeping compatibility with linux of course). So, keep your focus on the iPad version :)
Title: Re: New crashing thread
Post by: FrancesF on April 03, 2011, 06:56:33 pm
Dear achurch,

You wrote a patch!  That is so great!  Could you explain (as if to your computer literate, but non-programming, grandmother) exactly what I have to do step-by-step to integrate those patches (I just looked them up on Mercurial) into the game on my Mac?

Thank you so much,
FrancesF
Title: Re: New crashing thread
Post by: GMMan on April 03, 2011, 08:17:19 pm
I haven't developed on Mac , but I can name the prerequsites...
You'll need a copy of Mercurial, CMake, and a C++ compiler package (Xcode is the one from Apple). The other dependencies are included in the Mercurial repo.

Generic compiling instructions:
When you've installed all that, open up a Terminal (it's in a subfolder in the Apps folder), 'cd' to a directory that you will put all of Aquaria's source into, and run:
Code: [Select]
hg clone http://www.achurch.org/cgi-bin/hg/aquaria
Wait for the source to download, and then configure the source by running:
Code: [Select]
cmake CMakeLists.txt
and then, to build:
Code: [Select]
make
Check this page (Linux instructions): http://www.bit-blot.com/forum/index.php?topic=2304.msg28396#msg28396

Remember to copy the scripts included with the source or else your build won't run correctly.
Title: Re: New crashing thread
Post by: Sindhi on April 03, 2011, 08:18:40 pm
Thank you!
Title: Re: New crashing thread
Post by: FrancesF on April 03, 2011, 09:47:05 pm
Thanks, GMMan, I will try all that.

Frances
Title: Re: New crashing thread
Post by: achurch on April 04, 2011, 03:45:10 am
One quick addendum to GMMan's post.

If you want to use just the patch for the crash bug, but stay with the old script interface (the one your scripts are written for now), run this command before the "cmake" line:

Code: [Select]
hg update custom-entity-crash-fix
That will switch to the repository branch containing just that particular patch (plus a few others from the official repository on icculus.org), removing all the other changes I made.

If you later decide you want to try out the new script interface and other changes, you can go back to the main branch and build a new executable with:

Code: [Select]
make clean
hg update tip
cmake
make

(The "make clean" isn't always necessary, but CMake sometimes fails to notice file changes, so it's safest to clean up before changing branches.)
Title: Re: New crashing thread
Post by: FrancesF on April 04, 2011, 04:27:31 am
I've got to say there are more emotional ups and downs to moddling than I would have believed.  There's the exhilaration of seeing a creature you've drawn come alive and swim around of the screen, there's the surprise and chagrin when something you hadn't foreseen between creatures you've created occurs, and then there's the total frustration of working at something you don't really have the tools for yet, and is way over your head.  Right now I'd like to throw my computer in the trash!

Here's what I've done so far:  downloaded and installed CMake, Xcode, and Mercurial.  CMake and Xcode went right into the main Application folder and the Developer/ Application folder respectively, like good little apps.  Mercurial I can't find anywhere, although it said installation was successful each of the four or five times I installed it hoping it would show up.   I postponed that worry for a bit and googled what I didn't understand of GMMan's instructions: the "Terminal", "cd," "directories," and how to "run" something in the terminal.   So, I've got that the "Terminal" is an app included with Macs, that lets you directly work with the unix code, "cd" means change directory, and "directory" means file.

New questions:

1)  GMMan, when you say "Aquaria's source", which exact files do you mean?

2)  When you run something, do you type the instruction in the terminal window, for example
Quote
hg clone http://www.achurch.org/cgi-bin/hg/aquaria
and then just hit enter to make it run?

3)  Is there anything specific I need to name this file that I put the Aquaria source in, or can it just be anything, for example, "Aquaria-ent-fix"?

4)  When you say, "copy the scripts included with the source," which scripts do you mean?

Sorry to be so ignorant.  But I really do want to get some interesting new creatures into this mod!

Frances
Title: Re: New crashing thread
Post by: achurch on April 04, 2011, 06:21:32 am
I've got to say there are more emotional ups and downs to moddling than I would have believed.  There's the exhilaration of seeing a creature you've drawn come alive and swim around of the screen, there's the surprise and chagrin when something you hadn't foreseen between creatures you've created occurs, and then there's the total frustration of working at something you don't really have the tools for yet, and is way over your head.  Right now I'd like to throw my computer in the trash!

Don't worry, that's just to prepare you for the thrill of finally getting it working. (:

Mercurial I can't find anywhere, although it said installation was successful each of the four or five times I installed it hoping it would show up.

I presume you mean that you were able to download and install the Mercurial package itself, but it's not showing up in the Finder? That's as designed; Mercurial is strictly a command-line tool (though there are separate packages which let you use a GUI as well). If you open a Terminal window, type "hg" and press Enter, you should see something like:
Code: [Select]
Mercurial Distributed SCM

basic commands:

 add        add the specified files on the next commit
 annotate   show changeset information by line for each file
 clone      make a copy of an existing repository
...
 update     update working directory (or switch revisions)

use "hg help" for the full list of commands or "hg -v" for details
That'll tell you it installed successfully.

[...] and "directory" means file.

Not exactly -- "directory" is what you may know as "folder", i.e. something that contains other files (and possibly more directories -- in that case they're also referred to as "subdirectories" of the containing directory). "File" usually means a single unit of information, such as a text document.

New questions:

1)  GMMan, when you say "Aquaria's source", which exact files do you mean?

I think I can answer this; it's a reference to all the files that comprise the source code to Aquaria. This includes the game's Lua scripts, for example, and also includes the C++ source code (files whose names end in ".cpp" or ".h") for the game engine itself, along with various supporting files. If you run the "hg clone" command, you'll get all of these at once.

2)  When you run something, do you type the instruction in the terminal window, for example
Quote
hg clone http://www.achurch.org/cgi-bin/hg/aquaria
and then just hit enter to make it run?

Yes, that's correct.

3)  Is there anything specific I need to name this file that I put the Aquaria source in, or can it just be anything, for example, "Aquaria-ent-fix"?

When you run the "hg clone" command, the directory will be named "aquaria" by default, but yes, you can name it anything you want. To use a different name, add it at the end of the command line, separating it from the repository location with a space:
Quote
hg clone http://www.achurch.org/cgi-bin/hg/aquaria Aquaria-ent-fix

4)  When you say, "copy the scripts included with the source," which scripts do you mean?

When you download the source, there's a subdirectory of the top-level "aquaria" (or whatever you name it) directory called "game_scripts". Within this is another subdirectory called "scripts", which contains all the Lua scripts used by the game. (There's a second subdirectory at the same named "_mods", which has the Lua scripts for the mods included with the game such as the editor tutorial.) You'll need to copy the files in this subdirectory on top of the ones that came with the Aquaria distribution you downloaded.

To do this, first locate Aquaria in the Finder (right-click and select "Show in Finder"), then right-click on the Aquaria icon in the Finder window and select "Get Info". You'll see a line that looks like "Where: /Users/achurch/Applications" (the part after the colon will change depending on where it's installed). The text beginning with the first slash is the location of Aquaria's data, also known as its "path".

In a Terminal window, enter this command (replace the bolded part with the path from the Get Info window):
Quote
ls /Users/achurch/Applications/Aquaria.app/Contents/Resources/scripts
You should see a few subdirectories listed, like "entities" and "global". This is just to confirm that you have the right path for the scripts. Note that if the path contains a space in it, you need to enclose the entire path in double quotes:
Quote
ls "/Users/My User Name/Applications/Aquaria.app/Contents/Resources/scripts"

Then, after changing to the Aquaria source directory, run this command:
Quote
cp -a game_scripts/scripts game_scripts/_mods /Users/achurch/Applications/Aquaria.app/Contents/Resources/
This will overwrite your existing scripts with the scripts from the source code, which are needed to work with the new executable you build by running "make".

If you're worried about overwriting the data you downloaded, you can make a backup copy of the entire application using the Finder.

One timesaving hint, in case you're not aware, is that if you enter part of a file or directory name in the Terminal window and press the Tab key, Terminal will look for a file or directory with the path you typed and autocomplete the path, if possible. So in the above case, you could type "g<TAB>" instead of writing out "game_scripts/".

Also, I'm not sure it's been mentioned yet, but after you build an executable from the source code, you have to tell it where the game data is located before you can start the game. Enter this command, which only needs to be run once in any given Terminal window:
Quote
export AQUARIA_DATA_PATH=/Users/achurch/Applications/Aquaria.app/Contents/Resources
Then you can run the game itself from the Aquaria source directory with:
Quote
./aquaria

Sorry to be so ignorant.  But I really do want to get some interesting new creatures into this mod!

Not a problem -- that's how we all learn!
Title: Re: New crashing thread
Post by: FrancesF on April 04, 2011, 07:14:14 am
Yes!  I just verified that Mercurial is there.  I'll tackle the rest tomorrow...

Thank you, achurch  :)
Title: Re: New crashing thread
Post by: GMMan on April 04, 2011, 06:23:48 pm
@achurch: I'm trying a build right now, but it always gets stuck on freetype. It seems that it can't find ftconfig.h, though I know it's there. I can aleviate it a bit by manually inserting the #define in each of the files that use it, but there are too many files I'd have to do that to. So is it my source or is it my compiler? Maybe I should clean out my CMake cache.
Title: Re: New crashing thread
Post by: achurch on April 05, 2011, 02:44:24 am
FreeType's include system is a royal PITA. I assume you're building with internal FreeType (AQUARIA_INTERNAL_FREETYPE=TRUE)? I'll take a look and see if I borked up the include paths there.

EDIT: Hmm, a clean build with internal FreeType worked fine for me. I forget, are you using CMake or not? If not, you might want to doublecheck the compiler flags -- the CMakeFile adds a bunch of extra flags just for the FreeType sources.
Title: Re: New crashing thread
Post by: GMMan on April 05, 2011, 05:02:00 pm
All right, cleaning cache. Hopefully this time it will compile.

UPDATE: I think I figured it out. I read CMakeLists.txt and apparently I'm not supposed to be manually defining FreeType include dirs if I'm using internal. I removed all custom defined entries for libraries with the internal option, and I'm trying to compile again.

UPDATE2: I give up. I'm using a .lib file instead.