aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRatakor <ratakor@disroot.org>2023-08-27 22:36:36 -0400
committerRatakor <ratakor@disroot.org>2023-08-27 22:36:36 -0400
commit3eddabce763638bb11d261b86ab26d3c813c20a8 (patch)
treed95cdbe9e62256334f5ec26196718f5aaad4914e
parentb8d2bba45e9bf21714bf65731397faa1e4189866 (diff)
Fix bug raid ocr and change U32CAST and write_data
-rw-r--r--.gitignore1
-rw-r--r--src/Makefile2
-rw-r--r--src/nolan.h5
-rw-r--r--src/ocr.c8
-rw-r--r--src/raids.c4
5 files changed, 10 insertions, 10 deletions
diff --git a/.gitignore b/.gitignore
index e95de50..33aacf4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,5 @@
tests/
images/
nolan
-libre.a
config.h
compile_flags.txt
diff --git a/src/Makefile b/src/Makefile
index d165209..56eb03e 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -26,7 +26,7 @@ TESSLIBS = -ltesseract -lleptonica
GDLIBS = -lgd -lpng -lz -ljpeg -lfreetype -lm
WFLAGS = -pedantic -Werror -Wall -Wextra -Waggregate-return -Wshadow\
- -Wmissing-prototypes -Wunused-macros -Wdouble-promotion
+ -Wmissing-prototypes -Wunused-macros -Wdouble-promotion -Wpadded
CFLAGS += -std=c99 -D_DEFAULT_SOURCE ${WFLAGS}
LDFLAGS += ${DISCORDLIBS} ${TESSLIBS} ${GDLIBS}
diff --git a/src/nolan.h b/src/nolan.h
index fd90d52..8fecbb2 100644
--- a/src/nolan.h
+++ b/src/nolan.h
@@ -33,8 +33,7 @@
#define STRLEN(X) (sizeof(X) - 1)
#define UNUSED(X) ((void)(X))
#define VALID_STATS(X) (strchr(X, DELIM) == 0)
-#define U32CAST(player)\
- ((uint32_t *)((char *)(player) + MAX_USERNAME_SIZ + MAX_KINGDOM_SIZ) - 2)
+#define U32CAST(player) (&((player)->level))
enum {
NAME,
@@ -96,7 +95,7 @@ struct Player {
typedef struct {
char *name;
uint32_t damage;
- bool found_in_file;
+ int found_in_file;
} Slayer;
extern char *progname;
diff --git a/src/ocr.c b/src/ocr.c
index d5340f9..e3f38f0 100644
--- a/src/ocr.c
+++ b/src/ocr.c
@@ -12,7 +12,8 @@
/* meh */
#define DIFF 110
-#define WHITE 12000000
+/* #define WHITE 12000000 */
+#define WHITE 10000000
struct Slice {
char *data;
@@ -34,8 +35,8 @@ write_data(void *ptr, size_t siz, size_t nmemb, void *stream)
buf = (struct Slice *)stream;
buf->data = xrealloc(buf->data, buf->siz + siz + 1);
memcpy(buf->data + buf->siz, ptr, siz);
- buf->siz += siz + 1;
- buf->data[buf->siz - 1] = '\0';
+ buf->siz += siz;
+ buf->data[buf->siz] = '\0';
return buf->siz;
}
@@ -75,7 +76,6 @@ curl_file(char *url, char *fname)
return code;
}
-
int
write_rect(gdRect *rect, gdImage *im)
{
diff --git a/src/raids.c b/src/raids.c
index 6876c9f..26eb474 100644
--- a/src/raids.c
+++ b/src/raids.c
@@ -123,6 +123,9 @@ trim_dmg(char *str)
dmg = (dmg * 10) + (*p - "①"[2] + 1);
} while (*p++);
+ if (dmg > 100000000)
+ dmg /= 10;
+
return dmg;
}
@@ -376,7 +379,6 @@ overcap_msg(struct discord *client, u64snowflake channel_id, Slayer slayers[])
}
}
-
void
on_raids(struct discord *client, const struct discord_message *event)
{