📄 gamesupport.c
字号:
case 'V': /* change degen */ mvprintw(23, 0, "degen = %d; degen = ", playerp->p_degenerated); dtemp = infloat(); if (dtemp != 0.0) playerp->p_degenerated = (int) dtemp; continue; case 'W': /* change type */ prompt = "type"; sptr = &playerp->p_type; goto SALTER; case 'X': /* change special type */ prompt = "special type"; sptr = &playerp->p_specialtype; goto SALTER; case 'Y': /* change lives */ prompt = "lives"; sptr = &playerp->p_lives; goto SALTER; case 'Z': /* change crowns */ prompt = "crowns"; sptr = &playerp->p_crowns; goto SALTER; case '0': /* change charms */ prompt = "charm"; sptr = &playerp->p_charms; goto SALTER; case '1': /* change amulet */ prompt = "amulet"; sptr = &playerp->p_amulets; goto SALTER; case '2': /* change holy water */ prompt = "holy water"; sptr = &playerp->p_holywater; goto SALTER; case '3': /* change last-used */ prompt = "last-used"; sptr = &playerp->p_lastused; goto SALTER; case '4': /* change palantir */ prompt = "palantir"; bptr = &playerp->p_palantir; goto BALTER; case '5': /* change blessing */ prompt = "blessing"; bptr = &playerp->p_blessing; goto BALTER; case '6': /* change virgin */ prompt = "virgin"; bptr = &playerp->p_virgin; goto BALTER; case '7': /* change blindness */ prompt = "blindness"; bptr = &playerp->p_blindness; goto BALTER; case '8': /* change ring type */ prompt = "ring-type"; sptr = &playerp->p_ring.ring_type; goto SALTER; case '9': /* change ring duration */ prompt = "ring-duration"; sptr = &playerp->p_ring.ring_duration; goto SALTER; case '!': /* quit, update */ if (Wizard && (!ingameflag || playerp != &Player)) /* turn off status if not modifying self */ { playerp->p_status = S_OFF; playerp->p_tampered = T_OFF; } writerecord(playerp, loc); clear(); return; case '?': /* delete player */ if (ingameflag && playerp == &Player) /* cannot delete self */ continue; freerecord(playerp, loc); clear(); return; default: continue; }DALTER: mvprintw(23, 0, "%s = %f; %s = ", prompt, *dptr, prompt); dtemp = infloat(); if (dtemp != 0.0) *dptr = dtemp; continue;SALTER: mvprintw(23, 0, "%s = %d; %s = ", prompt, *sptr, prompt); dtemp = infloat(); if (dtemp != 0.0) *sptr = (short) dtemp; continue;BALTER: mvprintw(23, 0, "%s = %c; %s = ", prompt, flag[*bptr], prompt); c = getanswer("\nTF", TRUE); if (c == 'T') *bptr = TRUE; else if (c == 'F') *bptr = FALSE; continue; }}/**//************************************************************************// FUNCTION NAME: monstlist()// FUNCTION: print a monster listing// AUTHOR: E. A. Estes, 2/27/86// ARGUMENTS: none// RETURN VALUE: none// MODULES CALLED: puts(), fread(), fseek(), printf()// GLOBAL INPUTS: Curmonster, *Monstfp// GLOBAL OUTPUTS: none// DESCRIPTION:/ Read monster file, and print a monster listing on standard output.//************************************************************************/monstlist(){register int count = 0; /* count in file */ puts(" #) Name Str Brain Quick Energy Exper Treas Type Flock%\n"); fseek(Monstfp, 0L, 0); while (fread((char *) &Curmonster, SZ_MONSTERSTRUCT, 1, Monstfp) == 1) printf("%2d) %-20.20s%4.0f %4.0f %2.0f %5.0f %5.0f %2d %2d %3.0f\n", count++, Curmonster.m_name, Curmonster.m_strength, Curmonster.m_brains, Curmonster.m_speed, Curmonster.m_energy, Curmonster.m_experience, Curmonster.m_treasuretype, Curmonster.m_type, Curmonster.m_flock);}/**//************************************************************************// FUNCTION NAME: scorelist()// FUNCTION: print player score board// AUTHOR: E. A. Estes, 12/4/85// ARGUMENTS: none// RETURN VALUE: none// MODULES CALLED: fread(), fopen(), printf(), fclose()// GLOBAL INPUTS: // GLOBAL OUTPUTS: none// DESCRIPTION:/ Read the scoreboard file and print the contents.//************************************************************************/scorelist(){struct scoreboard sbuf; /* for reading entries */register FILE *fp; /* to open the file */ if ((fp = fopen(_PATH_SCORE, "r")) != NULL) { while (fread((char *) &sbuf, SZ_SCORESTRUCT, 1, fp) == 1) printf("%-20s (%-9s) Level: %6.0f Type: %s\n", sbuf.sb_name, sbuf.sb_login, sbuf.sb_level, sbuf.sb_type); fclose(fp); }}/**//************************************************************************// FUNCTION NAME: activelist()// FUNCTION: print list of active players to standard output// AUTHOR: E. A. Estes, 3/7/86// ARGUMENTS: none// RETURN VALUE: none// MODULES CALLED: descrstatus(), fread(), fseek(), printf(), descrtype()// GLOBAL INPUTS: Other, *Playersfp// GLOBAL OUTPUTS: none// DESCRIPTION:/ Read player file, and print list of active records to standard output.//************************************************************************/activelist(){ fseek(Playersfp, 0L, 0); printf("Current characters on file are:\n\n"); while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1) if (Other.p_status != S_NOTUSED) printf("%-20s (%-9s) Level: %6.0f %s (%s)\n", Other.p_name, Other.p_login, Other.p_level, descrtype(&Other, FALSE), descrstatus(&Other));}/**//************************************************************************// FUNCTION NAME: purgeoldplayers()// FUNCTION: purge inactive players from player file// AUTHOR: E. A. Estes, 12/4/85// ARGUMENTS: none// RETURN VALUE: none// MODULES CALLED: freerecord(), time(), fread(), fseek(), localtime()// GLOBAL INPUTS: Other, *Playersfp// GLOBAL OUTPUTS: none// DESCRIPTION:/ Delete characters which have not been used with the last/ three weeks.//************************************************************************/purgeoldplayers(){int today; /* day of year for today */int daysold; /* how many days since the character has been used */long ltime; /* time in seconds */long loc = 0L; /* location in file */ time(<ime); today = localtime(<ime)->tm_yday; for (;;) { fseek(Playersfp, loc, 0); if (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) != 1) break; daysold = today - Other.p_lastused; if (daysold < 0) daysold += 365; if (daysold > N_DAYSOLD) /* player hasn't been used in a while; delete */ freerecord(&Other, loc); loc += SZ_PLAYERSTRUCT; }}/**//************************************************************************// FUNCTION NAME: enterscore()// FUNCTION: enter player into scoreboard// AUTHOR: E. A. Estes, 12/4/85// ARGUMENTS: none// RETURN VALUE: none// MODULES CALLED: fread(), fseek(), fopen(), error(), strcmp(), fclose(), / strcpy(), fwrite(), descrtype()// GLOBAL INPUTS: Player// GLOBAL OUTPUTS: none// DESCRIPTION:/ The scoreboard keeps track of the highest character on a/ per-login basis./ Search the scoreboard for an entry for the current login,/ if an entry is found, and it is lower than the current player,/ replace it, otherwise create an entry.//************************************************************************/enterscore(){struct scoreboard sbuf; /* buffer to read in scoreboard entries */FILE *fp; /* to open scoreboard file */long loc = 0L; /* location in scoreboard file */bool found = FALSE; /* set if we found an entry for this login */ if ((fp = fopen(_PATH_SCORE, "r+")) != NULL) { while (fread((char *) &sbuf, SZ_SCORESTRUCT, 1, fp) == 1) if (strcmp(Player.p_login, sbuf.sb_login) == 0) { found = TRUE; break; } else loc += SZ_SCORESTRUCT; } else { error(_PATH_SCORE); /*NOTREACHED*/ } /* * At this point, 'loc' will either indicate a point beyond * the end of file, or the place where the previous entry * was found. */ if ((!found) || Player.p_level > sbuf.sb_level) /* put new entry in for this login */ { strcpy(sbuf.sb_login, Player.p_login); strcpy(sbuf.sb_name, Player.p_name); sbuf.sb_level = Player.p_level; strcpy(sbuf.sb_type, descrtype(&Player, TRUE)); } /* update entry */ fseek(fp, loc, 0); fwrite((char *) &sbuf, SZ_SCORESTRUCT, 1, fp); fclose(fp);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -