commit 07a368e0f3387e32f92a12775ca05625805e8e8d
parent a8f45e469f3abf7ee4573bc11b7fc24adb6a8232
Auteur: Selve <selve@asteride.xyz>
Date: Mon, 11 Mar 2024 18:24:43 -0400
abandon des phases
Diffstat:
2 files changed, 7 insertions(+), 17 deletions(-)
diff --git a/paquet.h b/paquet.h
@@ -11,8 +11,6 @@
#define PQ_DRAP_MNC 04 /* si la nouvelle question se trouve dans le monceau */
#define PQ_DRAP_ALEA 010 /* si les nouvelles fiches sont choisies aléatoirement */
-#define PQ_PHASE_N (1 << 15)
-
struct entete {
uint8_t version;
uint8_t draps;
diff --git a/sm2.c b/sm2.c
@@ -12,40 +12,32 @@ static uint8_t sm2_fac(int, int);
void
sm2(struct fiche *f, unsigned int qual, unsigned int pins, unsigned int pipi, unsigned int pnpi, uint64_t date) {
- int phase;
unsigned int nsucc;
uint32_t intrv;
uint64_t mtn;
- nsucc = f->nsucc & ~PQ_PHASE_N;
- phase = (f->nsucc & PQ_PHASE_N) > 0;
+ nsucc = f->nsucc;
f->fac = sm2_fac(f->fac, qual);
- if (qual >= 4 && nsucc < PQ_PHASE_N - 1)
+ if (qual >= 4)
nsucc++;
else
nsucc = 0;
- if (nsucc <= 1) {
- if (phase == 0)
- intrv = pipi;
- else
- intrv = pnpi;
- } else if (phase == 0 && nsucc == pins + 1) {
- phase = 1;
+ if (nsucc <= 1)
+ intrv = pipi;
+ else if (nsucc == pins + 1)
intrv = pnpi;
- } else {
- f->fac = sm2_fac(f->fac, qual);
+ else
intrv = (f->prch - f->dern) * (f->fac / 100.0 + FMIN) + 1;
- }
mtn = (uint64_t) time(NULL) >> 8;
f->dern = mtn - date;
f->prch = f->dern + intrv;
- f->nsucc = nsucc | (phase * PQ_PHASE_N);
+ f->nsucc = nsucc;
}
static uint8_t