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; }
/** * Hack -- change name */ void do_cmd_change_name(void) { ui_event ke; int col = 0; int last_line = 0; int top_line = 0; const char *p; /* Prompt */ p = "['c' change name, 'f' to file, scroll, or ESC]"; /* Save screen */ screen_save(); /* Adjust the buttons */ button_backup_all(); button_kill_all(); button_add("ESC", ESCAPE); button_add("Spc", ' '); button_add("-", '-'); button_add("c", 'c'); button_add("f", 'f'); button_add("->", ARROW_RIGHT); button_add("<-", ARROW_LEFT); p_ptr->redraw |= PR_BUTTONS; /* Make the array of lines */ C_WIPE(dumpline, DUMP_MAX_LINES, char_attr_line); last_line = make_dump(dumpline, 2); /* Forever */ while (1) { /* Display the player */ display_dump(dumpline, top_line, top_line + Term->hgt - 1, col); redraw_stuff(p_ptr); /* Clear the bottom line */ prt("", Term->hgt - 1, 0); /* Prompt */ Term_putstr(0, Term->hgt - 1, -1, TERM_WHITE, p); /* Query */ ke = inkey_ex(); /* Exit */ if (ke.key.code == ESCAPE) break; /* Change name */ if (ke.key.code == 'c') { char namebuf[32] = ""; if (get_name(namebuf, sizeof namebuf)) { /* Set player name */ my_strcpy(op_ptr->full_name, namebuf, sizeof(op_ptr->full_name)); /* Don't change savefile name. */ process_player_name(FALSE); } //(void) get_name(namebuf, sizeof namebuf); (void) make_dump(dumpline, 2); } /* File dump */ else if (ke.key.code == 'f') { char ftmp[80]; strnfmt(ftmp, sizeof ftmp, "%s.txt", op_ptr->base_name); if (get_string("File name: ", ftmp, 80)) { if (ftmp[0] && (ftmp[0] != ' ')) { if (file_character(ftmp, dumpline, last_line)) msg("Character dump failed!"); else msg("Character dump successful."); } } } /* Scroll down */ else if (ke.key.code == ARROW_DOWN) { if (top_line + Term->hgt - 2 < last_line) top_line++; } /* Page down */ else if (ke.key.code == ' ') { top_line = MIN(last_line - Term->hgt + 2, top_line + (Term->hgt - 2)); } /* Scroll up */ else if (ke.key.code == ARROW_UP) { if (top_line) top_line--; } /* Page up */ else if (ke.key.code == '-') { top_line -= (Term->hgt - 2) / 2; if (top_line < 0) top_line = 0; } /* Scroll left */ else if (ke.key.code == ARROW_LEFT) { if (col) col--; } /* Scroll right */ else if (ke.key.code == ARROW_RIGHT) { if (col < 32) col++; } /* Oops */ else { bell(NULL); } /* Flush messages */ message_flush(); } /* Adjust the buttons */ button_restore(); /* Load screen */ screen_load(); }