MCPcopy Create free account
hub / github.com/NetHack/NetHack / UseRIP

Method UseRIP

win/Qt/qt_menu.cpp:991–1074  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

989}
990
991void NetHackQtTextWindow::UseRIP(int how, time_t when)
992{
993// Code from X11 windowport
994#define STONE_LINE_LEN 16 /* # chars that fit on one line */
995#define NAME_LINE 0 /* line # for player name */
996#define GOLD_LINE 1 /* line # for amount of gold */
997#define DEATH_LINE 2 /* line # for death description */
998#define YEAR_LINE 6 /* line # for year */
999
1000 static char **rip_line = 0;
1001 if (!rip_line) {
1002 rip_line=new char*[YEAR_LINE+1];
1003 for (int i=0; i<YEAR_LINE+1; i++) {
1004 rip_line[i]=new char[STONE_LINE_LEN+1];
1005 }
1006 }
1007
1008 /* Follows same algorithm as genl_outrip() */
1009
1010 char buf[BUFSZ];
1011 char *dpx;
1012 int line;
1013
1014 /* Put name on stone */
1015 (void) snprintf(rip_line[NAME_LINE], STONE_LINE_LEN + 1,
1016 "%.*s", STONE_LINE_LEN, svp.plname);
1017
1018 /* Put $ on stone;
1019 to keep things safe and relatively simple, impose an arbitrary
1020 upper limit that's the same for 64 bit and 32 bit configurations
1021 (also 16 bit configurations provided they use 32 bit long); the
1022 upper limit for directly carried gold is somewhat less than 300K
1023 due to carrying capacity, but end-of-game handling has already
1024 added in gold from containers, so the amount could be much more
1025 (simplest case: ~300K four times in a blessed bag of holding, so
1026 ~1.2M; in addition to the hassle of getting such a thing set up,
1027 it would need many gold-rich bones levels or wizard mode wishing) */
1028 long cash = std::max(gd.done_money, 0L);
1029 /* force less that 10 digits to satisfy elaborate format checking;
1030 it's arbitrary but still way, way more than could ever be needed */
1031 if (cash < 0)
1032 cash = 0;
1033 if (cash > 999999999L)
1034 cash = 999999999L;
1035 (void) snprintf(rip_line[GOLD_LINE], STONE_LINE_LEN + 1, "%ld Au", cash);
1036
1037 /* Put together death description */
1038 formatkiller(buf, sizeof buf, how, FALSE);
1039 //str_copy(buf, killer, SIZE(buf));
1040
1041 /* Put death type on stone */
1042 for (line = DEATH_LINE, dpx = buf; line < YEAR_LINE; ++line) {
1043 char tmpchar;
1044 int i, i0 = (int) strlen(dpx);
1045
1046 if (i0 > STONE_LINE_LEN) {
1047 for (i = STONE_LINE_LEN; (i > 0) && (i0 > STONE_LINE_LEN); --i)
1048 if (dpx[i] == ' ')

Callers

nothing calls this directly

Calls 4

formatkillerFunction · 0.85
str_copyFunction · 0.85
yyyymmddFunction · 0.85
setLinesMethod · 0.45

Tested by

no test coverage detected