diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-04-15 10:04:38 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-04-15 10:04:38 +0800 |
commit | 4c520550cca32522e89fe01e2e0d3d172ed6b86d (patch) | |
tree | 60fc322c61a50438a8043e8cd48c845a5ee41ea7 /mbbsd | |
parent | a942aaef1cdde595f482a853e6a1291c04b9d2c7 (diff) | |
download | pttbbs-4c520550cca32522e89fe01e2e0d3d172ed6b86d.tar pttbbs-4c520550cca32522e89fe01e2e0d3d172ed6b86d.tar.gz pttbbs-4c520550cca32522e89fe01e2e0d3d172ed6b86d.tar.bz2 pttbbs-4c520550cca32522e89fe01e2e0d3d172ed6b86d.tar.lz pttbbs-4c520550cca32522e89fe01e2e0d3d172ed6b86d.tar.xz pttbbs-4c520550cca32522e89fe01e2e0d3d172ed6b86d.tar.zst pttbbs-4c520550cca32522e89fe01e2e0d3d172ed6b86d.zip |
- bbs: fix utmp_brcid out-of-sync on 's' select.
- visio: change unified handle (VSOREF) to typed ref, and utilize new APIs
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4165 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/assess.c | 4 | ||||
-rw-r--r-- | mbbsd/bbs.c | 8 | ||||
-rw-r--r-- | mbbsd/go.c | 8 | ||||
-rw-r--r-- | mbbsd/gomo.c | 7 | ||||
-rw-r--r-- | mbbsd/kaede.c | 3 | ||||
-rw-r--r-- | mbbsd/reversi.c | 7 | ||||
-rw-r--r-- | mbbsd/visio.c | 43 |
7 files changed, 50 insertions, 30 deletions
diff --git a/mbbsd/assess.c b/mbbsd/assess.c index c1bb90ed..25847c13 100644 --- a/mbbsd/assess.c +++ b/mbbsd/assess.c @@ -93,7 +93,7 @@ u_fixgoodpost(void) } while (!endinput && newgp < MAXGP) { - int y, x = 0; + int y; boardheader_t *bh = NULL; move(1, 0); clrtobot(); @@ -123,7 +123,7 @@ u_fixgoodpost(void) bh = getbcache(bid); strlcpy(bname, bh->brdname, sizeof(bname)); prints("已找到看板 --> %s\n", bname); - getyx(&y, &x); + y = vgety(); // loop AID query while (newgp < MAXGP) diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index 035bc8a6..9c165bc0 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -4084,8 +4084,12 @@ ReadSelect(void) Read(); changed = 1; } - // no need to set utmpbid here... - // setutmpbid(0); + // need to set utmpbid here... + // because Read() just restores settings. + // and 's' directly calls here. + // so if we don't reset then utmpbid will be out-of-sync. + // fix someday... + setutmpbid(0); currutmp->mode = mode0; currstat = stat0; return changed; @@ -834,8 +834,8 @@ go_genlog(ChessInfo* info, FILE* fp, ChessGameResult result) const static char ColName[] = "ABCDEFGHJKLMNOPQRST"; const int nStep = info->history.used; char buf[ANSILINELEN] = ""; - int i, x, y; - int sethand = 0; + int i, sethand = 0; + VREFCUR cur; if (nStep > 0) { const go_step_t* const step = @@ -844,14 +844,14 @@ go_genlog(ChessInfo* info, FILE* fp, ChessGameResult result) sethand = step->loc.r; } - getyx(&y, &x); + cur = vcur_save(); for (i = 1; i <= 22; i++) { move(i, 0); inansistr(buf, sizeof(buf)-1); fprintf(fp, "%s\n", buf); } - move(y, x); + vcur_restore(cur); fprintf(fp, "\n"); fprintf(fp, "按 z 可進入打譜模式\n"); diff --git a/mbbsd/gomo.c b/mbbsd/gomo.c index b18fe5d0..5507913f 100644 --- a/mbbsd/gomo.c +++ b/mbbsd/gomo.c @@ -422,16 +422,17 @@ gomo_genlog(ChessInfo* info, FILE* fp, ChessGameResult result) { char buf[ANSILINELEN] = ""; const int nStep = info->history.used; - int i, x, y; + int i; + VREFCUR cur; - getyx(&y, &x); + cur = vcur_save(); for (i = 1; i <= 18; i++) { move(i, 0); inansistr(buf, sizeof(buf)-1); fprintf(fp, "%s\n", buf); } - move(y, x); + vcur_restore(cur); fprintf(fp, "\n"); fprintf(fp, "按 z 可進入打譜模式\n"); diff --git a/mbbsd/kaede.c b/mbbsd/kaede.c index 321d52e8..c3a8f797 100644 --- a/mbbsd/kaede.c +++ b/mbbsd/kaede.c @@ -116,8 +116,7 @@ outslr(const char *left, int leftlen, const char *right, int rightlen) void out_lines(const char *str, int line) { - int y, x; - getyx(&y, &x); + int y = vgety(); while (*str && line) { if (*str == '\n') { diff --git a/mbbsd/reversi.c b/mbbsd/reversi.c index d29d8613..eec0c8c3 100644 --- a/mbbsd/reversi.c +++ b/mbbsd/reversi.c @@ -345,16 +345,17 @@ reversi_genlog(ChessInfo* info, FILE* fp, ChessGameResult result) { char buf[ANSILINELEN] = ""; const int nStep = info->history.used; - int i, x, y; + int i; + VREFCUR cur; - getyx(&y, &x); + cur = vcur_save(); for (i = 2; i <= 21; i++) { move(i, 0); inansistr(buf, sizeof(buf)-1); fprintf(fp, "%s\n", buf); } - move(y, x); + vcur_restore(cur); fprintf(fp, "\n"); fprintf(fp, "按 z 可進入打譜模式\n"); diff --git a/mbbsd/visio.c b/mbbsd/visio.c index 59a69c2e..b4845f59 100644 --- a/mbbsd/visio.c +++ b/mbbsd/visio.c @@ -27,6 +27,11 @@ #define SAFE_MAX_COL (MAX_COL-1) #define VBUFLEN (ANSILINELEN) +// this is a special strlen to speed up processing. +// warning: x MUST be #define x "msg". +// otherwise you need to use real strlen. +#define MACROSTRLEN(x) (sizeof(x)-1) + // ---- UTILITIES ---------------------------------------------------- inline void outnc(int n, unsigned char c) @@ -41,17 +46,12 @@ nblank(int n) outnc(n, ' '); } -// this is a special strlen to speed up processing. -// warning: x MUST be #define x "msg". -// otherwise you need to use real strlen. -#define MACROSTRLEN(x) (sizeof(x)-1) - -// ---- VSOREF API -------------------------------------------------- +// ---- VREF API -------------------------------------------------- /** * vscr_save(): 傳回目前畫面的備份物件。 */ -VSOREF +VREFSCR vscr_save(void) { // TODO optimize memory allocation someday. @@ -65,9 +65,9 @@ vscr_save(void) * vscr_restore(obj): 使用並刪除畫面的備份物件。 */ void -vscr_restore(VSOREF obj) +vscr_restore(VREFSCR obj) { - screen_backup_t *o = (screen_backup_t*)o; + screen_backup_t *o = (screen_backup_t*)obj; if (o) { scr_restore(o); @@ -79,24 +79,25 @@ vscr_restore(VSOREF obj) /** * vcur_save(): 傳回目前游標的備份物件。 */ -VSOREF +VREFCUR vcur_save(void) { // XXX 偷懶不 new object 了, pointer 夠大 int y, x; + VREFCUR v; getyx(&y, &x); - y = ((unsigned short)y << 16) | (unsigned short)x; - return (VSOREF)NULL + y; + v = ((unsigned short)y << 16) | (unsigned short)x; + return v; } /** * vcur_restore(obj): 使用並刪除游標的備份物件。 */ void -vcur_restore(VSOREF o) +vcur_restore(VREFCUR o) { int y, x; - y = (unsigned int)(o - NULL); + y = (unsigned int)(o); x = (unsigned short)(y & 0xFFFF); y = (unsigned short)(y >> 16); move(y, x); @@ -124,6 +125,20 @@ vpad(int n, const char *pattern) if (n) nblank(n); } +/** + * vgety(): 取得目前所在位置的行數 + * + * 考慮到 ANSI 系統,getyx() 較為少用且危險。 + * vgety() 安全而明確。 + */ +inline int +vgety(void) +{ + int y, x; + getyx(&y, &x); + return y; +} + // ---- HIGH LEVEL API ----------------------------------------------- /** |