summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2013-11-04 19:21:11 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2013-11-04 19:21:11 +0800
commita93bb214ce2698401603370f73412e92cf232996 (patch)
tree3b5cd31b7b200024b55e5b83c1fc1daf00db7a01
parent10987d794b243ba28765bca75dee32d212376634 (diff)
downloadpttbbs-a93bb214ce2698401603370f73412e92cf232996.tar
pttbbs-a93bb214ce2698401603370f73412e92cf232996.tar.gz
pttbbs-a93bb214ce2698401603370f73412e92cf232996.tar.bz2
pttbbs-a93bb214ce2698401603370f73412e92cf232996.tar.lz
pttbbs-a93bb214ce2698401603370f73412e92cf232996.tar.xz
pttbbs-a93bb214ce2698401603370f73412e92cf232996.tar.zst
pttbbs-a93bb214ce2698401603370f73412e92cf232996.zip
Improve chicken debug code.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5894 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--pttbbs/mbbsd/chicken.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/pttbbs/mbbsd/chicken.c b/pttbbs/mbbsd/chicken.c
index b504fef7..682a1a9b 100644
--- a/pttbbs/mbbsd/chicken.c
+++ b/pttbbs/mbbsd/chicken.c
@@ -517,8 +517,23 @@ static void debug_rpt(const char *msg GCC_UNUSED, chicken_t *c GCC_UNUSED) {
msg = "";
clear();
}
- prints("%s hp:%d/%d weight:%d sick:%d dirty:%d\n",
- msg, c->hp, c->hp_max, c->weight, c->sick, c->dirty);
+ if (c) {
+ prints("%s hp:%d/%d weight:%d sick:%d dirty:%d\n",
+ msg, c->hp, c->hp_max, c->weight, c->sick, c->dirty);
+ } else {
+ vmsg(msg);
+ }
+#endif
+}
+
+static void debug_timediff(chicken_t *c GCC_UNUSED) {
+#ifdef DBG_CHICKEN
+ char buf[7];
+ vs_hdr2("寵物", "測試");
+ getdata(2, 0, "要模擬幾小時未進入的狀態?", buf, sizeof(buf), NUMECHO);
+ syncnow();
+ if (*buf)
+ c->lastvisit = now - atoi(buf) * 60 * 60;
#endif
}
@@ -597,10 +612,7 @@ time_diff(chicken_t * thechicken)
if (thechicken->hp > thechicken->hp_max)
thechicken->hp = thechicken->hp_max;
debug_rpt("AFTER hp-recovery", thechicken);
-
-#ifdef DBG_CHICKEN
- pressanykey();
-#endif
+ debug_rpt("time_diff", NULL);
}
static void
@@ -932,6 +944,7 @@ chicken_query(const char *userid)
clrtobot();
prints("\n\n%s 並沒有養寵物..", userid);
} else {
+ debug_timediff(&xchicken);
time_diff(&xchicken);
if (!isdeath(&xchicken, NULL))
{
@@ -959,18 +972,7 @@ chicken_main(void)
int age;
chicken_t *mychicken = load_live_chicken(cuser.userid);
-
-#ifdef DBG_CHICKEN
- {
- char buf[5];
- vs_hdr2("寵物", "測試");
- getdata(2, 0, "要模擬幾小時未進入的狀態?", buf, sizeof(buf), NUMECHO);
- syncnow();
- if (*buf)
- mychicken->lastvisit = now - atoi(buf) * 60 * 60;
- }
-#endif
-
+ debug_timediff(mychicken);
lockreturn0(CHICKEN, LOCK_MULTI);
if (mychicken && !mychicken->name[0])
{