KrampusHack 2020 FINISHED

And here is my entry: a space shooter !

RazorCrest (click here to download)

Task (for NunoMartinez):

Finally, here it is my wishlist:
* Fast game. I mean that you can play a complete “play” in few minutes.
* Minimalistic graphics. Don’t make them complex.
* Finally, select one of your own wishes.

How I achieved the rules:

  • Fast game. I mean that you can play a complete “play” in few minutes.
    ===> You start it you play
  • Minimalistic graphics. Don’t make them complex.
    ===> Only 4 sprites and they are very basic due to my drawing style, the rest is only circles, triangles and rectangles
  • Finally, select one of your own wishes.
    ===> Particles !!!

How to play:

-up to start moving
-arrows to move the ship
=> more XP = quicker
-use the mouse to aim and use mouse button or key CTRL to fire
=> more XP = more and better bullets, better accuracy
-green monsters are light enemies that are just traveling here
-yellow monsters are aggressives enemies that are targeting you
-red monsters are very aggressives enemies that are targeting you, and they are more solid
-the more you kill the more power you have to kill
-hitting the walls or being hit by an enemy makes you loose life and XP (thus fire power)

Screenshots:

Building from source:

-Go with a shell into to SRC/KRAMPUSHACK2020
-Type make
-If it works move the binary to ../..
-If it’s not working, come and complain here :-p

Hint for finishing

-Because the ship can speed up does not mean you should use it all the time
-Kill as much as you can on first levels so you have the firepower for next levels
-Use thrust/slow down/side jumps to avoid enemies while shooting at them

Portable non GNU TEMP_FAILURE_ENTRY macro

In addition to that subject Here is a portable macro that can be used in place of TEMP_FAILURE_ENTRY, without GNU_SOURCE (took from stackoverflow):

#define CALL_RETRY(retvar, expression) do { \
    retvar = (expression); \
} while (retvar == -1 && errno == EINTR);
/* call example */
SOCKET s ;
char buf[ 4096 ] = "" ;
int retval = -1 ;
/* ... stripped socket initialisation code ... */
CALL_RETRY( br , recv( s , buf , 1024, 0 ) );

In case you receive a “interrupted system calls” signal, there is a chance that this trick may help / guide you to the answer.

#gdb #socket #linux #redhat #EINTR #recv #send

X11 / xserver / XWIN gvim problems

Case:

WARNING**: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files

Solved by adding NO_AT_BRIDGE=1 before launching gvim ( i.e [user@server]$ NO_AT_BRIDGE=1 gvim myfile.txt) source: https://github.com/NixOS/nixpkgs/issues/16327

Case:

connect /tmp/.X11-unix/X0: Permission denied
E233: cannot open display
Press ENTER or type command to continue

Solved by using correct DISPLAY informations before connecting (DISPLAY=localhost:0.0) source: https://unix.stackexchange.com/a/220234

execve: no such file or directory

If one day when using execve you encounter the “no such file or directory” problem, and that the file you tried to launch is really existing and with the good rights, then the problem is coming from the shebang not pointing to a valid interpreter.

In example: #!/bin/ksh and ksh is not installed

#reminder #execve

New to GDB or in need of good ressources about it ?

Here you go:
https://www.st.com/resource/en/user_manual/usermanual_debugging_with_gdb-user-manual–debugging-with-gdb-for-stm32cubeide-stmicroelectronics.pdf

That manual I stumbled upon while searching for some informations on how to configure gdb is THE thing.

From starting to crashing, each possible good analysis is covered in that manual.

Good reading !

#debugger #code #gdb

Easier pthread mutex deadlock detection

Thread programming is fun, starting a tons of process and syncing them on a task, or asynchronously process a bunch of data. But that fun is having a cost: data sharing have to be somewhat locked or well ordered when accessing it. Else you’re going to face some seriously strange situations like time warping variables at the best and big crashes at worse.

On top of that let’s add that the main tools to protect our datas reads / writes by threads can also lead to strange situations where only parts of the code is still running and the rest is in “deadlock” state.

On little examples detecting those deadlocks seems easy, but when scaled to a bigger project/api, it’s a living hell.
Tools like valgrind may detect the problems at the cost of big performance loss which may lead to being unable to run into the problem before running into the machine limits.

I was searching for a good ressource to help me in my debugging quest when I stumbled upon that article from Aurelian Melinte which I think is very good (both the author and article): https://linuxgazette.net/150/melinte.html that provide some code samples to superseed the pthread functions with some that will make some checks during the calls.

There is also the gdb deadlock detector script by DamZiobro : https://github.com/DamZiobro/gdb-automatic-deadlock-detector

And finally valgrind- helgrind: http://valgrind.org/docs/manual/hg-manual.html

Now back to code and monitoring/debugging !



Cross platform correct socket error code

A friend using my networking code made the good point that it was not correctly reporting errors on some windows compilers.

I hope we got this sorted out.

Grab / update your code from the git repo: https://framagit.org/GullRaDriel/nilorea-library

Added:
-netw_unload() =>macro who calls WSACleanup . Call it before exiting (on OK or error). Does nothing on *nix/*nux


-netw_set_blocking(…) => set blocking mode on a network

Internals:
-neterr => WSAGetLastError or errno
-netstrerr => FormatMessage or strerror (strerror_r wrapper is quoted because not working on redhat)

This has caused a full revamping of all error management, but now it’s ok. Valgrind checked.

#nilorea-library #networking #winsock #socket

Micro$oft and sockets

Microsoft, have you ever done something as bad as your pesky winsock wrapper around classic sockets ? (correct Berkeley’s error code support for FTW)And your way of always reinventing the wheel at your sauce is FUCKING BORING (Hell yeah, why just use open source? Let’s just add a bunch of proprietary shit inside ==> all those boring WINAPIs which are BTW NOT PORTABLE).

It’s BOOOORING, booooring , booooooooring. (Did I add enough ‘o’ ? Because I think you didn’t add enough WSAshit everywhere)

Now I have to make a proper wrapper because you, as a big company, are not able to follow the standards and make things simple and portable. Micro$oft.

From MSDN: “This means, for example, that checking for errors when the socket and accept functions return should not be done by comparing the return value with –1, or seeing if the value is negative (both common and legal approaches in UNIX). Instead, an application should use the manifest constant INVALID_SOCKET as defined in the Winsock2.h header file.”

Hell yeah, let’s review all our calls to check for a specific Windows code….#ShitNumber1

Also: WSAGetLastError() == WSAEWOULDBLOCK , yeah, yeah, why just use common naming convention when you can add WSAshit everywhere ?

Lets not just talk about the FormatMessage function. Using strerror would have been too much for you to handle, it’s a single line func with a single parameter.

#Bored#GrumpyCoder#Microsoft#Windows#Winsock#API#WSAshitFunctions