bool send_world_score(bool do_send) { #ifdef WORLD_SCORE if(send_score && do_send) { if(easy_band) { msg_print("Since you are in the Easy Mode, you cannot send score to world score server."); } else if(get_check_strict("Do you send score to the world score sever? ", (CHECK_NO_ESCAPE | CHECK_NO_HISTORY))) { errr err; prt("",0,0); prt("Sending...",0,0); Term_fresh(); screen_save(); err = report_score(); screen_load(); if (err) { return FALSE; } prt("Completed. Hit any key.", 0, 0); (void)inkey(); } else return FALSE; } #endif return TRUE; }
/*! * @brief スコアサーバへの転送処理 * @param do_send 実際に転送ア処置を行うか否か * @return 転送が成功したらTRUEを返す */ bool send_world_score(bool do_send) { #ifdef WORLD_SCORE if(send_score && do_send) { if(easy_band) { msg_print(_("初心者モードではワールドスコアに登録できません。", "Since you are in the Easy Mode, you cannot send score to world score server.")); } else if(get_check_strict(_("スコアをスコア・サーバに登録しますか? ", "Do you send score to the world score sever? "), (CHECK_NO_ESCAPE | CHECK_NO_HISTORY))) { errr err; prt("",0,0); prt(_("送信中..", "Sending..."),0,0); Term_fresh(); screen_save(); err = report_score(); screen_load(); if (err) { return FALSE; } prt(_("完了。何かキーを押してください。", "Completed. Hit any key."), 0, 0); (void)inkey(); } else return FALSE; } #endif return TRUE; }
errr report_score(void) { #ifdef MACINTOSH OSStatus err; #else errr err = 0; #endif #ifdef WINDOWS WSADATA wsaData; WORD wVersionRequested =(WORD) (( 1) | ( 1 << 8)); #endif BUF *score; int sd; char seikakutmp[128]; score = buf_new(); sprintf(seikakutmp, "%s ", ap_ptr->title); buf_sprintf(score, "name: %s\n", player_name); buf_sprintf(score, "version: Hengband %d.%d.%d\n", FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH); buf_sprintf(score, "score: %d\n", total_points()); buf_sprintf(score, "level: %d\n", p_ptr->lev); buf_sprintf(score, "depth: %d\n", dun_level); buf_sprintf(score, "maxlv: %d\n", p_ptr->max_plv); buf_sprintf(score, "maxdp: %d\n", max_dlv[DUNGEON_ANGBAND]); buf_sprintf(score, "au: %d\n", p_ptr->au); buf_sprintf(score, "turns: %d\n", turn_real(turn)); buf_sprintf(score, "sex: %d\n", p_ptr->psex); buf_sprintf(score, "race: %s\n", rp_ptr->title); buf_sprintf(score, "class: %s\n", cp_ptr->title); 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", p_ptr->died_from); buf_sprintf(score, "-----charcter dump-----\n"); make_dump(score); if (screen_dump) { buf_sprintf(score, "-----screen shot-----\n"); buf_append(score, screen_dump, strlen(screen_dump)); } #ifdef WINDOWS if (WSAStartup(wVersionRequested, &wsaData)) { msg_print("Report: WSAStartup failed."); goto report_end; } #endif #ifdef MACINTOSH #if TARGET_API_MAC_CARBON err = InitOpenTransportInContext(kInitOTForApplicationMask, NULL); #else err = InitOpenTransport(); #endif if (err != noErr) { msg_print("Report: OpenTransport failed."); return 1; } #endif Term_clear(); while (1) { char buff[160]; prt("connecting...", 0, 0); Term_fresh(); /* プロキシを設定する */ 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; sprintf(buff, "Failed to connect to the score server.(%s)", soc_err()); prt(buff, 0, 0); (void)inkey(); if (!get_check_strict("Try again? ", CHECK_NO_HISTORY)) { err = 1; goto report_end; } } prt("Sending the score...", 0, 0); Term_fresh(); http_post(sd, SCORE_PATH, score); disconnect_server(sd); report_end: #ifdef WINDOWS WSACleanup(); #endif #ifdef MACINTOSH #if TARGET_API_MAC_CARBON CloseOpenTransportInContext(NULL); #else CloseOpenTransport(); #endif #endif return err; }