summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/bbs/cache.c3
-rw-r--r--include/pttstruct.h3
-rw-r--r--include/uflags.h2
-rw-r--r--mbbsd/menu.c30
-rw-r--r--mbbsd/user.c2
-rw-r--r--upgrade/r4856_adbanner.c54
6 files changed, 75 insertions, 19 deletions
diff --git a/common/bbs/cache.c b/common/bbs/cache.c
index 19d5b895..cd2b4a4a 100644
--- a/common/bbs/cache.c
+++ b/common/bbs/cache.c
@@ -791,6 +791,9 @@ reload_pttcache(void)
} // end of .DIR loop
fclose(fp);
+ if (strcmp(item.title+3, "點歌") == 0)
+ SHM->last_usong = id - 1;
+
// decide next aggressive state
if (rawid && aggid*3 >= rawid) // if aggressive exceed 1/3
set_aggressive_state(1);
diff --git a/include/pttstruct.h b/include/pttstruct.h
index 1be9f2a1..fb6fb78e 100644
--- a/include/pttstruct.h
+++ b/include/pttstruct.h
@@ -559,8 +559,7 @@ typedef struct {
char gap_20[sizeof(int)];
msgque_t loginmsg; /* 進站水球 */
int last_film;
- // FIXME remove it
- int __never_used__max_history;
+ int last_usong;
time4_t Puptime;
time4_t Ptouchtime;
int Pbusystate;
diff --git a/include/uflags.h b/include/uflags.h
index d0414db0..5192fcce 100644
--- a/include/uflags.h
+++ b/include/uflags.h
@@ -22,8 +22,8 @@
#define FRIEND_FLAG 0x00000010 /* true if show friends only */
#define BRDSORT_FLAG 0x00000020 /* true if the boards sorted alphabetical */
#define ADBANNER_FLAG 0x00000040 /* (was: MOVIE_FLAG, true if show advertisement banner */
+#define ADBANNER_USONG_FLAG 0x00000080 /* true if show user songs in banner */
/* deprecated flag */
-//#define COLOR_FLAG 0x00000080 /* true if the color mode open */
//#define MIND_FLAG 0x00000100 /* true if mind search mode open <-Heat*/
/* DBCS CONFIG */
diff --git a/mbbsd/menu.c b/mbbsd/menu.c
index 828dcd97..d982130d 100644
--- a/mbbsd/menu.c
+++ b/mbbsd/menu.c
@@ -240,18 +240,13 @@ show_status(void)
* xyz.c: adbanner(999999); // logout
* menu.c: adbanner(cmdmode); // ...
*/
-#define N_SYSADBANNER (sizeof(adbanner_map) / sizeof(adbanner_map[0]))
+#define N_SYSADBANNER 13
void
adbanner(int cmdmode)
{
int i;
// adbanner 前幾筆是 Note 板精華區「<系統> 動態看板」(SYS) 目錄下的文章
- // adbanner_map 是用來依 cmdmode 挑出特定的動態看板,index 跟 mode_map 一樣。
- const int adbanner_map[] = {
- 2, 10, 11, -1, 3, -1, 12,
- 7, 9, 8, 4, 5, 6,
- };
// don't show if stat in class or user wants to skip adbanners
if (currstat == CLASS || !(cuser.uflag & ADBANNER_FLAG))
@@ -260,9 +255,8 @@ adbanner(int cmdmode)
if (SHM->Pbusystate || SHM->last_film <= 0)
return;
- if (cmdmode < N_SYSADBANNER &&
- 0 < adbanner_map[cmdmode] && adbanner_map[cmdmode] <= SHM->last_film) {
- i = adbanner_map[cmdmode];
+ if (cmdmode > 0 && cmdmode < N_SYSADBANNER && cmdmode < SHM->last_film) {
+ i = cmdmode;
} else if (cmdmode == 999999) { /* Goodbye my friend */
i = 0;
} else {
@@ -273,9 +267,14 @@ adbanner(int cmdmode)
// can one ADBANNER to display" to slide through every banners in one hour.
// @ now / (3600 / MAx_ADBANNER) means "get the index of which to show".
// syncnow();
- if (SHM->last_film > N_SYSADBANNER)
- i = N_SYSADBANNER + (now / (3600 / MAX_ADBANNER) ) %
- (SHM->last_film+1-N_SYSADBANNER);
+
+ if (SHM->last_film > N_SYSADBANNER) {
+ if (cuser.uflag & ADBANNER_USONG_FLAG)
+ i = N_SYSADBANNER + (now / (3600 / MAX_ADBANNER) ) %
+ (SHM->last_film+1-N_SYSADBANNER);
+ else i = SHM->last_usong + 1 + (now / (3600 / MAX_ADBANNER) ) %
+ (SHM->last_film - SHM->last_usong);
+ }
else
i = 0; // SHM->last_film;
}
@@ -340,11 +339,10 @@ static const int mode_map[] = {
static void
domenu(int cmdmode, const char *cmdtitle, int cmd, const commands_t cmdtable[])
{
- int lastcmdptr, adbannermode;
+ int lastcmdptr;
int n, pos, total, i;
int err;
- adbannermode = cmdmode;
assert(cmdmode < M_XMAX);
cmdmode = mode_map[cmdmode];
@@ -352,7 +350,7 @@ domenu(int cmdmode, const char *cmdtitle, int cmd, const commands_t cmdtable[])
showtitle(cmdtitle, BBSName);
- total = show_menu(adbannermode, cmdtable);
+ total = show_menu(cmdmode, cmdtable);
show_status();
lastcmdptr = pos = 0;
@@ -474,7 +472,7 @@ domenu(int cmdmode, const char *cmdtitle, int cmd, const commands_t cmdtable[])
if (refscreen) {
showtitle(cmdtitle, BBSName);
- show_menu(adbannermode, cmdtable);
+ show_menu(-1, cmdtable);
show_status();
refscreen = NA;
}
diff --git a/mbbsd/user.c b/mbbsd/user.c
index a08217e5..899d7c11 100644
--- a/mbbsd/user.c
+++ b/mbbsd/user.c
@@ -368,6 +368,7 @@ void Customize(void)
/* cuser.uflag settings */
static const unsigned int masks1[] = {
ADBANNER_FLAG,
+ ADBANNER_USONG_FLAG,
NO_MODMARK_FLAG ,
COLORED_MODMARK,
#ifdef DBCSAWARE
@@ -380,6 +381,7 @@ void Customize(void)
static const char* desc1[] = {
"動態看板",
+ "動態看板顯示心情點播",
"隱藏文章修改符號(推文/修文) (~)",
"改用色彩代替修改符號 (+)",
#ifdef DBCSAWARE
diff --git a/upgrade/r4856_adbanner.c b/upgrade/r4856_adbanner.c
new file mode 100644
index 00000000..031b7885
--- /dev/null
+++ b/upgrade/r4856_adbanner.c
@@ -0,0 +1,54 @@
+#define _UTIL_C_
+#include "bbs.h"
+#include <time.h>
+
+int transform(userec_t *new, userec_t *old, int i)
+{
+ userec_t *u = new;
+
+ memcpy(new, old, sizeof(userec_t));
+
+ if (!u->userid[0])
+ return 0;
+
+ u->uflag &= ~ADBANNER_USONG_FLAG;
+
+ // force convert!
+ // passwd_update(n+1, u);
+
+ return 0;
+}
+
+int main(void)
+{
+ int fd, fdw;
+ userec_t new;
+ userec_t old;
+ int i = 0;
+
+ printf("sizeof(userec_t)=%u\n", (unsigned int)sizeof(userec_t));
+ printf("You're going to convert your .PASSWDS\n");
+ printf("The new file will be named .PASSWDS.trans.tmp\n");
+
+ if (chdir(BBSHOME) < 0) {
+ perror("chdir");
+ exit(-1);
+ }
+
+ if ((fd = open(FN_PASSWD, O_RDONLY)) < 0 ||
+ (fdw = open(FN_PASSWD".trans.tmp", O_WRONLY | O_CREAT | O_TRUNC, 0600)) < 0 ) {
+ perror("open");
+ exit(-1);
+ }
+
+ while (read(fd, &old, sizeof(old)) > 0) {
+ transform(&new, &old, ++i);
+ write(fdw, &new, sizeof(new));
+ }
+
+ close(fd);
+ close(fdw);
+
+ // printf("total %d records converted.\n", accs);
+ return 0;
+}