OSDN Git Service

Extend features of tiling. (separation of Cell size and Tile size / add offset position.)
[hengband/hengband.git] / src / report.c
index a9a585e..9829bd7 100644 (file)
 #include <signal.h>
 #endif
 
+/*
+ * internet resource value
+ */
+#define HTTP_PROXY ""                   /* Default proxy url */
+#define HTTP_PROXY_PORT 0               /* Default proxy port */
+#define HTTP_TIMEOUT    20              /* Timeout length (second) */
+#define SCORE_SERVER "www.kmc.gr.jp"    /* Default score server url */
+#define SCORE_PORT 80                   /* Default score server port */
+
 #ifdef JP
 #define SCORE_PATH "http://www.kmc.gr.jp/~habu/local/hengscore/score.cgi"
 #else
@@ -49,25 +58,6 @@ typedef struct {
 
 #define        BUFSIZE (65536)
 
-#ifndef HAVE_VASPRINTF
-#define vasprintf      Vasprintf
-
-static int Vasprintf(char **buf, const char *fmt, va_list ap)
-{
-       int ret;
-
-       *buf = malloc(1024);
-
-#if defined(HAVE_VSNPRINTF)
-       ret = vsnprintf(*buf, 1024, fmt, ap);
-#else
-       ret = vsprintf(*buf, fmt, ap);
-#endif
-       return ret;
-}
-
-#endif /* ifndef HAVE_VASPRINTF */ 
-
 static BUF* buf_new(void)
 {
        BUF *p;
@@ -114,28 +104,41 @@ static int buf_append(BUF *buf, const char *data, size_t size)
 static int buf_sprintf(BUF *buf, const char *fmt, ...)
 {
        int             ret;
-       char    *tmpbuf;
+       char    tmpbuf[8192];
        va_list ap;
 
        va_start(ap, fmt);
-       vasprintf(&tmpbuf, fmt, ap);
+#if defined(HAVE_VSNPRINTF)
+       ret = vsnprintf(tmpbuf, sizeof(tmpbuf), fmt, ap);
+#else
+       ret = vsprintf(tmpbuf, fmt, ap);
+#endif
        va_end(ap);
 
-       if(!tmpbuf) return -1;
+       if (ret < 0) return -1;
 
-#ifdef MAC_MPW
+#if ('\r' == 0x0a && '\n' == 0x0d)
        {
-               /* '\n' is 0x0D and '\r' is 0x0A in MPW. Swap back these. */
+               /*
+                * Originally '\r'= CR (= 0x0d) and '\n'= LF (= 0x0a)
+                * But for MPW (Macintosh Programers Workbench), these
+                * are reversed so that '\r'=LF and '\n'=CR unless the
+                * -noMapCR option is not defined.
+                *
+                * We need to swap back these here since the score
+                * dump text should be written using LF as the end of
+                * line.
+                */
                char *ptr;
                for (ptr = tmpbuf; *ptr; ptr++)
-                       if ('\n' == *ptr) *ptr = '\r';
+               {
+                       if (0x0d == *ptr) *ptr = 0x0a;
+               }
        }
 #endif
 
        ret = buf_append(buf, tmpbuf, strlen(tmpbuf));
 
-       free(tmpbuf);
-
        return ret;
 }
 
@@ -170,7 +173,7 @@ static int buf_search(BUF *buf, const char *str)
 {
        char *ret;
 
-       ret = strstr(buf->data, str);
+       ret = my_strstr(buf->data, str);
 
        if (!ret) return -1;
 
@@ -291,6 +294,9 @@ cptr make_screen_dump(void)
 
        if (old_use_graphics)
        {
+               /* Clear -more- prompt first */
+               msg_print(NULL);
+
                use_graphics = FALSE;
                reset_visuals();
 
@@ -428,7 +434,7 @@ errr report_score(void)
        buf_sprintf(score, "seikaku: %s\n", seikakutmp);
        buf_sprintf(score, "realm1: %s\n", realm_names[p_ptr->realm1]);
        buf_sprintf(score, "realm2: %s\n", realm_names[p_ptr->realm2]);
-       buf_sprintf(score, "killer: %s\n", died_from);
+       buf_sprintf(score, "killer: %s\n", p_ptr->died_from);
        buf_sprintf(score, "-----charcter dump-----\n");
 
        make_dump(score);
@@ -472,7 +478,13 @@ errr report_score(void)
 #endif
                Term_fresh();
                
-               sd = connect_scoreserver();
+               /* ¥×¥í¥­¥·¤òÀßÄꤹ¤ë */
+               set_proxy(HTTP_PROXY, HTTP_PROXY_PORT);
+
+               /* Connect to the score server */
+               sd = connect_server(HTTP_TIMEOUT, SCORE_SERVER, SCORE_PORT);
+
+
                if (!(sd < 0)) break;
 #ifdef JP
                sprintf(buff, "¥¹¥³¥¢¡¦¥µ¡¼¥Ð¤Ø¤ÎÀܳ¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£(%s)", soc_err());