Re: tetris(6) "Random Generator" and advanced controls

2022-09-11 Thread Tom MTT.
ping?



Re: tetris(6) "Random Generator" and advanced controls

2022-08-28 Thread Stuart Henderson
On 2022/08/27 19:58, Tom MTT. wrote:
> Apparently, as some people pointed it out, DMARC doesn't influence spam score.

Depends on the mail server doing filtering.

> I thought that since my e-mail failed both SPF and DKIM and my DMARC
> policy was set to quarantine my mail would've been trashed instantly.

openbsd.org lists *strip* dkim headers anyway, so recipients with a strict
dmarc setup are unlikely to receive mail from sending domains with p=reject 
policy.

> I'm really sorry for the inconvenience, I won't do the same mistake twice.
> 
> ~ tmtt
> 



Re: tetris(6) "Random Generator" and advanced controls

2022-08-27 Thread Tom MTT.
Apparently, as some people pointed it out, DMARC doesn't influence spam score.
I thought that since my e-mail failed both SPF and DKIM and my DMARC
policy was set to quarantine my mail would've been trashed instantly.

I'm really sorry for the inconvenience, I won't do the same mistake twice.

~ tmtt



tetris(6) "Random Generator" and advanced controls

2022-08-27 Thread Tom MTT.
Hi all!
Due to a misconfiguration of my domain's DMARC record, my previous mail
went directly into your spam folders. Now that it's fixed, I'm sending
it again. Hope that doesn't cause too much trouble.

I made some changes to tetris(6) to follow the Tetris guidelines more
closely and to add new controls and features.

Among the (visible) changes:
- The random shape generator now picks a shape from a shuffled "bag"
  (a 7 ints array), thus preventing extremely long runs without a
  desired shape, and on the other hand to have the same piece 4 times
  in a row.

- New controls have been added, a player can now rotate the active shape
  counterclockwise, clockwise and by 180�. The player can also soft drop
  (i.e. move the shape down), without influencing the score, unlike the
  hard drop.

- There's now a "hold" control, which allows the player to swap the active
  shape with the one in the hold space. If there's none, the active shape
  is moved into the hold space and the next shape comes into the board.
  The hold action can only be used once, until the next randomly-chosen
  shapes comes. The shape in that space is kept as-is until the player
  decides to put it back on the board.

  Maybe we should put that thing as a command-line flag and penalizes
  the score if enabled, like the preview of the next shape? Let me know.

- The manpage has been modified to add the new controls and features.
  A "TODO" section has been created with the features that I'd like
  to implement in the future (like a ghost shape and support for arrow
  keys in the -k flag).

Now, the internal changes:
- A shape preview function has been created to facilitate.. the preview
  of shapes.

- Trailing whitespaces and tabs have been removed. (Actually, I didn't
  even do it myself, my editor config just removes them automagically.)

I did my best to follow OpenBSD's code style in the changes I made.
It's my first contribution, hope I didn't make too many mistakes!

Thanks for your time, and have a great day/evening/night!
~ tmtt



Index: screen.c
===
RCS file: /cvs/src/games/tetris/screen.c,v
retrieving revision 1.19
diff -u -p -u -p -r1.19 screen.c
--- screen.c28 Jun 2019 13:32:52 -  1.19
+++ screen.c26 Aug 2022 19:35:42 -
@@ -138,6 +138,45 @@ put(int c)
 #definemoveto(r, c)putpad(tgoto(CMstr, c, r))
 
 /*
+ * Shape preview.
+ */
+void
+preview_shape(const struct shape *piece, char *text, int r, int c)
+{
+   int tr, tc, t, i;
+
+   /* clean */
+   putpad(SEstr);
+   moveto(r-1, c-1); putstr("  ");
+   moveto(r,   c-1); putstr("  ");
+   moveto(r+1, c-1); putstr("  ");
+   moveto(r+2, c-1); putstr("  ");
+
+   moveto(r-3, c-2);
+   putstr(text);
+
+   /* draw */
+   if (piece != NULL) {
+   if (SOstr)
+   putpad(SOstr);
+
+   moveto(r, 2 * c);
+   putstr(SOstr ? "  " : "[]");
+   for (i = 0; i < 3; i++) {
+   t = c + r * B_COLS;
+   t += piece->off[i];
+
+   tr = t / B_COLS;
+   tc = t % B_COLS;
+
+   moveto(tr, 2*tc);
+   putstr(SOstr ? "  " : "[]");
+   }
+   putpad(SEstr);
+   }
+}
+
+/*
  * Set up from termcap.
  */
 void
@@ -165,7 +204,7 @@ scr_init(void)
{"sg", &sgnum},
{ {0}, NULL}
};
-   
+
if ((term = getenv("TERM")) == NULL)
stop("you must set the TERM environment variable");
if (tgetent(tbuf, term) <= 0)
@@ -370,6 +409,7 @@ scr_update(void)
int i, ccol, j;
sigset_t sigset, osigset;
static const struct shape *lastshape;
+   static const struct shape *lastholdshape;
 
sigemptyset(&sigset);
sigaddset(&sigset, SIGTSTP);
@@ -387,41 +427,22 @@ scr_update(void)
curscore = score;
}
 
+   static int r, c;
+   int tr, tc, t;
+
/* draw preview of next pattern */
if (showpreview && (nextshape != lastshape)) {
-   static int r=5, c=2;
-   int tr, tc, t;
-
lastshape = nextshape;
+   preview_shape(nextshape, "Next shape:", 12, 2);
+   }
 
-   /* clean */
-   putpad(SEstr);
-   moveto(r-1, c-1); putstr("  ");
-   moveto(r,   c-1); putstr("  ");
-   moveto(r+1, c-1); putstr("  ");
-   moveto(r+2, c-1); putstr("  ");
-
-   moveto(r-3, c-2);
-   putstr("Next shape:");
-
-   /* draw */
-   if (SOstr)
-   putpad(SOstr);
-   moveto(r, 2 * c);
-   putstr(SOstr ? "  " : "[]");
-   for (i = 0; i < 3; i++) {
-   t = c +