summary refs log tree commit diff
diff options
context:
space:
mode:
authorLain Iwakura <lain@lainmail.xyz>2026-01-04 14:09:00 +0300
committerLain Iwakura <lain@lainmail.xyz>2026-01-04 14:09:00 +0300
commit1ef7f328bc3ad76dcf0449a78a4e4ba9e9cb1762 (patch)
tree4f3c8a23e4c472f017e97f3087bd6f9e8225036b
parentMake copyrights consistent (diff)
downloadplay-1ef7f328bc3ad76dcf0449a78a4e4ba9e9cb1762.tar.gz
play-1ef7f328bc3ad76dcf0449a78a4e4ba9e9cb1762.zip
feat(linux): some patches
-rw-r--r--2048.c10
-rw-r--r--Makefile2
-rw-r--r--freecell.c11
-rw-r--r--play.c2
-rw-r--r--shell.nix14
5 files changed, 36 insertions, 3 deletions
diff --git a/2048.c b/2048.c
index e2129da..3f92e5d 100644
--- a/2048.c
+++ b/2048.c
@@ -18,9 +18,16 @@
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <time.h>
 
 typedef unsigned uint;
 
+#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
+static uint arc4random_uniform(uint upper_bound) {
+	return rand() % upper_bound;
+}
+#endif
+
 static uint score;
 static uint grid[4][4];
 
@@ -274,6 +281,9 @@ static bool input(void) {
 }
 
 uint play2048(void) {
+#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
+	srand(time(NULL));
+#endif
 	curse();
 	spawn();
 	spawn();
diff --git a/Makefile b/Makefile
index 6296390..b5ae932 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@ CHROOT_USER = play
 CHROOT_GROUP = ${CHROOT_USER}
 
 CFLAGS += -std=c11 -Wall -Wextra
-LDFLAGS = -static
+LDFLAGS =
 LDLIBS = -lncursesw
 
 -include config.mk
diff --git a/freecell.c b/freecell.c
index 8a4ef94..0b77e6f 100644
--- a/freecell.c
+++ b/freecell.c
@@ -25,6 +25,12 @@
 #include <unistd.h>
 
 typedef unsigned uint;
+
+#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
+static uint arc4random_uniform(uint upper_bound) {
+	return rand() % upper_bound;
+}
+#endif
 typedef unsigned char byte;
 
 typedef byte Card;
@@ -257,7 +263,7 @@ static void drawCard(bool hi, int y, int x, Card card) {
 
 static void drawStack(bool hi, int y, int x, const struct Stack *stack) {
 	for (uint i = 0; i < stack->len; ++i) {
-		drawCard(hi && i == stack->len-1, y++, x, stack->cards[i]);
+		drawCard(hi && (int)i == (int)stack->len-1, y++, x, stack->cards[i]);
 	}
 }
 
@@ -399,6 +405,9 @@ static void input(void) {
 }
 
 uint playFreeCell(void) {
+#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
+	srand(time(NULL));
+#endif
 	game = 1 + arc4random_uniform(32000);
 	curse();
 	deal(game);
diff --git a/play.c b/play.c
index 1f9dad9..98c7aa7 100644
--- a/play.c
+++ b/play.c
@@ -239,7 +239,7 @@ static const struct Game *menu(void) {
 		attrset(A_NORMAL);
 		addstr("You can select a game directly using ");
 		attrset(A_BOLD);
-		addstr("ssh -t play@ascii.town ");
+		addstr("ssh -t play@ssh.iwakura.page");
 		addstr(Games[game].name);
 		attrset(A_NORMAL);
 		clrtoeol();
diff --git a/shell.nix b/shell.nix
new file mode 100644
index 0000000..511a808
--- /dev/null
+++ b/shell.nix
@@ -0,0 +1,14 @@
+{ pkgs ? import <nixpkgs> {} }:
+
+pkgs.mkShell {
+  buildInputs = with pkgs; [
+    ncurses
+    zlib
+    ctags
+  ];
+  
+  shellHook = ''
+    export NIX_CFLAGS_COMPILE="-I${pkgs.ncurses.dev}/include -I${pkgs.zlib.dev}/include"
+    export NIX_LDFLAGS="-L${pkgs.ncurses.out}/lib -L${pkgs.zlib.out}/lib"
+  '';
+}