summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/libbbsutil.h7
-rw-r--r--include/modes.h7
-rw-r--r--mbbsd/chicken.c25
-rw-r--r--mbbsd/gamble.c2
-rw-r--r--mbbsd/mbbsd.c2
-rw-r--r--mbbsd/stuff.c24
-rw-r--r--mbbsd/user.c7
7 files changed, 52 insertions, 22 deletions
diff --git a/include/libbbsutil.h b/include/libbbsutil.h
index a825ff28..3acebdfc 100644
--- a/include/libbbsutil.h
+++ b/include/libbbsutil.h
@@ -11,8 +11,13 @@
#else
#define GCC_CHECK_FORMAT(a,b)
#endif
+
+
+// flags used by strip_ansi
enum STRIP_FLAG {
- STRIP_ALL = 0, ONLY_COLOR, NO_RELOAD
+ STRIP_ALL = 0,
+ ONLY_COLOR, // allow only colors (ESC [ .. m)
+ NO_RELOAD // allow all known (color+move)
};
enum LOG_FLAG {
LOG_CREAT = 1,
diff --git a/include/modes.h b/include/modes.h
index 0c79bb3c..689a2853 100644
--- a/include/modes.h
+++ b/include/modes.h
@@ -207,4 +207,11 @@ enum _DBCS_STATUS {
#define PAGER_MODES (5)
+/* stuff.c: show_file */
+#define SHOWFILE_RAW (0x00)
+#define SHOWFILE_ALLOW_COLOR (0x01) // ESC [ ... m
+#define SHOWFILE_ALLOW_MOVE (0x02) // ESC [ ... H
+#define SHOWFILE_ALLOW_STAR (0x04) // ESC * ...
+#define SHOWFILE_ALLOW_ALL (SHOWFILE_ALLOW_COLOR | SHOWFILE_ALLOW_MOVE | SHOWFILE_ALLOW_STAR)
+
#endif
diff --git a/mbbsd/chicken.c b/mbbsd/chicken.c
index c6360749..bf03a4c1 100644
--- a/mbbsd/chicken.c
+++ b/mbbsd/chicken.c
@@ -281,6 +281,12 @@ show_chicken_stat(const chicken_t * thechicken, int age)
#define CHICKEN_PIC "etc/chickens"
+static void
+show_chicken_picture(const char *fpath)
+{
+ show_file(fpath, 5, 14, SHOWFILE_ALLOW_ALL);
+}
+
void
show_chicken_data(chicken_t * thechicken, chicken_t * pkchicken)
{
@@ -300,7 +306,8 @@ show_chicken_data(chicken_t * thechicken, chicken_t * pkchicken)
snprintf(buf, sizeof(buf), CHICKEN_PIC "/%c%d", thechicken->type + 'a',
age > 16 ? 16 : age);
- show_file(buf, 5, 14, NO_RELOAD);
+
+ show_chicken_picture(buf);
move(18, 0);
@@ -364,7 +371,7 @@ ch_eat(chicken_t *mychicken)
mychicken->food--;
move(10, 10);
- show_file(CHICKEN_PIC "/eat", 5, 14, NO_RELOAD);
+ show_chicken_picture(CHICKEN_PIC "/eat");
pressanykey();
}
}
@@ -375,7 +382,7 @@ ch_clean(chicken_t *mychicken)
mychicken->clean = 0;
mychicken->tiredstrong +=
time_change[(int)mychicken->type][TIREDSTRONG] / 3;
- show_file(CHICKEN_PIC "/clean", 5, 14, NO_RELOAD);
+ show_chicken_picture(CHICKEN_PIC "/clean");
pressanykey();
}
@@ -409,7 +416,7 @@ ch_book(chicken_t *mychicken)
{
mychicken->book += time_change[(int)mychicken->type][BOOK];
mychicken->tiredstrong += time_change[(int)mychicken->type][TIREDSTRONG];
- show_file(CHICKEN_PIC "/read", 5, 14, NO_RELOAD);
+ show_chicken_picture(CHICKEN_PIC "/read");
pressanykey();
}
@@ -420,7 +427,7 @@ ch_kiss(chicken_t *mychicken)
mychicken->satis += time_change[(int)mychicken->type][SATIS];
mychicken->tiredstrong +=
time_change[(int)mychicken->type][TIREDSTRONG] / 2;
- show_file(CHICKEN_PIC "/kiss", 5, 14, NO_RELOAD);
+ show_chicken_picture(CHICKEN_PIC "/kiss");
pressanykey();
}
@@ -441,7 +448,7 @@ ch_hit(chicken_t *mychicken)
if (mychicken->satis > 2)
mychicken->satis -= 2;
mychicken->tiredstrong += time_change[(int)mychicken->type][TIREDSTRONG];
- show_file(CHICKEN_PIC "/hit", 5, 14, NO_RELOAD);
+ show_chicken_picture(CHICKEN_PIC "/hit");
pressanykey();
}
@@ -463,7 +470,7 @@ ch_buyitem(int money, const char *picture, int *item, int haveticket)
vice(money * num, "購買寵物,賭盤項目");
else
demoney(-money * num);
- show_file(picture, 5, 14, NO_RELOAD);
+ show_chicken_picture(picture);
pressanykey();
} else {
vmsg("現金不夠 !!!");
@@ -479,7 +486,7 @@ ch_eatoo(chicken_t *mychicken)
mychicken->tiredstrong = 0;
if (mychicken->happy > 5)
mychicken->happy -= 5;
- show_file(CHICKEN_PIC "/oo", 5, 14, NO_RELOAD);
+ show_chicken_picture(CHICKEN_PIC "/oo");
pressanykey();
}
}
@@ -495,7 +502,7 @@ ch_eatmedicine(chicken_t *mychicken)
mychicken->hp = mychicken->hp_max;
if (mychicken->happy > 10)
mychicken->happy -= 10;
- show_file(CHICKEN_PIC "/medicine", 5, 14, NO_RELOAD);
+ show_chicken_picture(CHICKEN_PIC "/medicine");
pressanykey();
}
}
diff --git a/mbbsd/gamble.c b/mbbsd/gamble.c
index ec959c2d..2f3e2dd7 100644
--- a/mbbsd/gamble.c
+++ b/mbbsd/gamble.c
@@ -70,7 +70,7 @@ show_ticket_data(char betname[MAX_ITEM][MAX_ITEM_LEN],const char *direct, int *p
snprintf(genbuf, sizeof(genbuf), "%s/" FN_TICKET_END, direct);
end = 1;
}
- show_file(genbuf, 8, -1, NO_RELOAD);
+ show_file(genbuf, 8, -1, SHOWFILE_ALLOW_ALL);
move(15, 0);
outs(ANSI_COLOR(1;32) "目前下注狀況:" ANSI_RESET "\n");
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c
index 8f62ad7e..0c561ed1 100644
--- a/mbbsd/mbbsd.c
+++ b/mbbsd/mbbsd.c
@@ -688,7 +688,7 @@ login_query(void)
move(1, 0);
prints("debugging mode\ncurrent pid: %d\n", getpid());
#else
- show_file("etc/Welcome", 1, -1, NO_RELOAD);
+ show_file("etc/Welcome", 1, -1, SHOWFILE_ALLOW_ALL);
#endif
// XXX why output("1", 1); here?
// this output has been here since rev 1...
diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c
index 7f2ddd04..2349a68d 100644
--- a/mbbsd/stuff.c
+++ b/mbbsd/stuff.c
@@ -400,7 +400,7 @@ vmsgf(const char *fmt,...)
* @param filename
* @param x
* @param lines
- * @param mode
+ * @param mode: SHOWFILE_*, see modes.h
* @return 失敗傳回 0,否則為 1。
* 2 表示有 PttPrints 碼
*/
@@ -410,6 +410,12 @@ show_file(const char *filename, int y, int lines, int mode)
FILE *fp;
char buf[1024];
int ret = 1;
+ int strpmode = STRIP_ALL;
+
+ if (mode & SHOWFILE_ALLOW_COLOR)
+ strpmode = ONLY_COLOR;
+ if (mode & SHOWFILE_ALLOW_MOVE)
+ strpmode = NO_RELOAD;
if (y >= 0)
move(y, 0);
@@ -418,15 +424,19 @@ show_file(const char *filename, int y, int lines, int mode)
while (fgets(buf, sizeof(buf), fp) && lines--)
{
move(y++, 0);
- // because Ptt_prints escapes are not so often,
- // let's try harder to detect it.
- if (strstr(buf, ESC_STR "*") != NULL)
+ if (mode == SHOWFILE_RAW)
+ {
+ outs(buf);
+ }
+ else if ((mode & SHOWFILE_ALLOW_STAR) && (strstr(buf, ESC_STR "*") != NULL))
{
- outs(Ptt_prints(buf, sizeof(buf), mode));
+ // because Ptt_prints escapes are not so often,
+ // let's try harder to detect it.
+ outs(Ptt_prints(buf, sizeof(buf), strpmode));
ret = 2;
} else {
// ESC is very common...
- strip_ansi(buf, buf, mode);
+ strip_ansi(buf, buf, strpmode);
outs(buf);
}
}
@@ -574,7 +584,7 @@ void
show_helpfile(const char *helpfile)
{
clear();
- show_file((char *)helpfile, 0, b_lines, NO_RELOAD);
+ show_file((char *)helpfile, 0, b_lines, SHOWFILE_ALLOW_ALL);
#ifdef PLAY_ANGEL
if (HasUserPerm(PERM_LOGINOK))
pressanykey_or_callangel();
diff --git a/mbbsd/user.c b/mbbsd/user.c
index 47cfb674..6d4b25cd 100644
--- a/mbbsd/user.c
+++ b/mbbsd/user.c
@@ -102,7 +102,8 @@ int u_cancelbadpost(void)
cuser.timeremovebadpost = now;
passwd_update(usernum, &cuser);
log_filef("log/cancelbadpost.log", LOG_CREAT,
- "%s %s 刪除一篇劣文\n", Cdate(&now), cuser.userid);
+ "%s %s 刪除一篇劣文 (現 %d 篇)\n",
+ Cdate(&now), cuser.userid, cuser.badpost);
}
vmsg("恭喜您已經成功\刪除一篇劣文.");
return 0;
@@ -1084,14 +1085,14 @@ showplans_userec(userec_t *user)
/* 棋國國徽 */
setapath(genbuf, bcache[kingdom_bid - 1].brdname);
strlcat(genbuf, "/chess_ensign", sizeof(genbuf));
- show_file(genbuf, 13, 10, ONLY_COLOR);
+ show_file(genbuf, 13, 10, SHOWFILE_ALLOW_COLOR);
return;
}
}
#endif /* defined(CHESSCOUNTRY) */
sethomefile(genbuf, user->userid, fn_plans);
- if (!show_file(genbuf, 7, MAX_QUERYLINES, ONLY_COLOR))
+ if (!show_file(genbuf, 7, MAX_QUERYLINES, SHOWFILE_ALLOW_COLOR))
prints("《個人名片》%s 目前沒有名片", user->userid);
}