Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crack-attack: enable sound support in the crack-attack game. #22905

Closed
wants to merge 1 commit into from

Conversation

SuzanneSoy
Copy link

@SuzanneSoy SuzanneSoy commented Feb 17, 2017

Motivation for this change

The crack-attack game can have sound if the user-supplied sound files are present in its configuration folder. However, this needs the --enable-sound configure option to be enabled. Note that the option on its own does not activate the sounds, the files must be added to the configuration folder (see the commit message for more info).


The --enable-sound ./configure option enables the sound support in crack-attack.
This commit enables the --enable-sound option, and adds a dependency on SDL_mixer.
The following files still have to be supplied by the user, due to licencing issues upstream:

~/.crack-attack/music/game.ogg
~/.crack-attack/music/gameover.ogg
~/.crack-attack/music/prelude.ogg
~/.crack-attack/music/youwin.ogg
~/.crack-attack/sounds/block_awaking.wav
~/.crack-attack/sounds/block_dying.wav
~/.crack-attack/sounds/block_fallen.wav
~/.crack-attack/sounds/countdown.wav
~/.crack-attack/sounds/garbage_fallen.wav
~/.crack-attack/sounds/garbage_shattering.wav

The crack-attack game will detect when these sound files are present, and use them as background music and sound effects.

Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@mention-bot
Copy link

@jsmaniac, thanks for your PR! By analyzing the history of the files in this pull request, we identified @Fuuzetsu, @aske and @globin to be potential reviewers.

@joachifm
Copy link
Contributor

The build fails with

/nix/store/[...]-SDL_mixer-1.2.12/include/SDL/SDL_mixer.h:27:23: fatal error: SDL_types.h: No such file or directory

Please consider enabling sandboxing to help eliminate implicit dependencies.

@SuzanneSoy
Copy link
Author

@joachifm I tried building it with nix-env -f $NIXPKGS --option nix.useSandbox true -iA crack_attack, and it build fine here (is that command okay? I couldn't find where to enable the useSandbox otherwise, /etc/nixos/configuration.nix complains that there is no such option if I add it there). Also, that file (SDL_types.h) is provided by the SDL package, which is already part of the build inputs for crack-attack. Any idea about what's happening here?

@joachifm
Copy link
Contributor

joachifm commented Feb 21, 2017

@jsmaniac if you're using nix-daemon, you can't control sandboxing that way (in a multi-user environment, some of the point of sandboxing would be lost if users could control it). Sandboxing is configured in nix.conf via nix.useSandbox or nix.useChroot if you're on an older NixOS.

One thing you could try something like NIX_CFLAGS_COMPILE = "-I${SDL.dev}/include" (or wherever the supposedly missing file resides); it's kind of ugly, but at least then you can ensure it'll be in the include path. Then again, adding SDL to inputs ought to be sufficient, if the headers are in a standard location ...

@SuzanneSoy
Copy link
Author

SuzanneSoy commented Feb 21, 2017

@joachifm Thanks for the help. I had omitted the nix. prefix when adding useSandbox to my /etc/nixos/configure.nix. I still can't reproduce the error, and noticed that on the Travis build, the following flags are omitted (but they are used when I build locally). I don't know why this happens, it's as if nix ignores some of the buildInputs.

-I/nix/store/3r7hrfi9ywgbx7wpv1kpjy8w2855p7ak-SDL-1.2.15-dev/include/SDL -I/nix/store/3r7hrfi9ywgbx7wpv1kpjy8w2855p7ak-SDL-1.2.15-dev/include/SDL -I/nix/store/lr4p15vdd35ixb3i1x1f25pf4k9aq75n-SDL_mixer-1.2.12/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT

Several other games use the hack you mentioned, so I added this to crack-attack's default.nix too, this should hopefully be enough.

NIX_CFLAGS_COMPILE = "-I${SDL.dev}/include/SDL";

@SuzanneSoy SuzanneSoy force-pushed the crack-attack-sound branch 2 times, most recently from e8ba49d to 26fd583 Compare February 24, 2017 00:48
The --enable-sound ./configure option enables the sound support in crack-attack.
This commit enables the --enable-sound option, and adds a dependency on SDL_mixer.
The following files still have to be supplied by the user, due to licencing issues upstream:

~/.crack-attack/music/game.ogg
~/.crack-attack/music/gameover.ogg
~/.crack-attack/music/prelude.ogg
~/.crack-attack/music/youwin.ogg
~/.crack-attack/sounds/block_awaking.wav
~/.crack-attack/sounds/block_dying.wav
~/.crack-attack/sounds/block_fallen.wav
~/.crack-attack/sounds/countdown.wav
~/.crack-attack/sounds/garbage_fallen.wav
~/.crack-attack/sounds/garbage_shattering.wav

The crack-attack game will detect when these sound files are present, and use them as background music and sound effects.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants