-/* $NetBSD: global.c,v 1.11 2008/02/03 21:24:58 dholland Exp $ */
+/* $NetBSD: global.c,v 1.14 2012/06/19 05:30:43 dholland Exp $ */
/*
* global.c Larn is copyrighted 1986 by Noah Morgan.
* losemhp(x) subroutine to remove max # hit points from the player
* raisehp(x) subroutine to gain hit points
* raisemhp(x) subroutine to gain maximum hit points
- * losespells(x) subroutine to lose spells
* losemspells(x) subroutine to lose maximum spells
- * raisespells(x) subroutine to gain spells
* raisemspells(x) subroutine to gain maximum spells
- * recalc() function to recalculate the armor class of the player
* makemonst(lev) function to return monster number for a randomly
* selected monster
* positionplayer() function to be sure player is not in a wall
+ * recalc() function to recalculate the armor class of the player
* quit() subroutine to ask if the player really wants to quit
*/
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: global.c,v 1.11 2008/02/03 21:24:58 dholland Exp $");
+__RCSID("$NetBSD: global.c,v 1.14 2012/06/19 05:30:43 dholland Exp $");
#endif /* not lint */
#include <string.h>
extern char *what[], *who[];
extern char winner[];
extern char sciv[SCORESIZE + 1][26][2];
-extern char *password;
+extern const char *password;
/*
- ***********
- RAISE LEVEL
- ***********
raiselevel()
subroutine to raise the player one level
uses c[EXPERIENCE] c[LEVEL]
*/
void
-raiselevel()
+raiselevel(void)
{
if (c[LEVEL] < MAXPLEVEL)
raiseexperience((long) (skill[c[LEVEL]] - c[EXPERIENCE]));
}
/*
- ***********
- LOOSE LEVEL
- ***********
loselevel()
subroutine to lower the players character level by one
*/
void
-loselevel()
+loselevel(void)
{
if (c[LEVEL] > 1)
loseexperience((long) (c[EXPERIENCE] - skill[c[LEVEL] - 1] + 1));
}
/*
- ****************
- RAISE EXPERIENCE
- ****************
raiseexperience(x)
subroutine to increase experience points
*/
void
-raiseexperience(x)
- long x;
+raiseexperience(long x)
{
int i, tmp;
i = c[LEVEL];
}
/*
- ****************
- LOOSE EXPERIENCE
- ****************
loseexperience(x)
subroutine to lose experience points
*/
void
-loseexperience(x)
- long x;
+loseexperience(long x)
{
int i, tmp;
i = c[LEVEL];
}
/*
- ********
- LOOSE HP
- ********
losehp(x)
losemhp(x)
warning -- will kill player if hp goes to zero
*/
void
-losehp(x)
- int x;
+losehp(int x)
{
if ((c[HP] -= x) <= 0) {
beep();
}
void
-losemhp(x)
- int x;
+losemhp(int x)
{
c[HP] -= x;
if (c[HP] < 1)
}
/*
- ********
- RAISE HP
- ********
raisehp(x)
raisemhp(x)
subroutine to gain maximum hit points
*/
void
-raisehp(x)
- int x;
+raisehp(int x)
{
if ((c[HP] += x) > c[HPMAX])
c[HP] = c[HPMAX];
}
void
-raisemhp(x)
- int x;
+raisemhp(int x)
{
c[HPMAX] += x;
c[HP] += x;
}
/*
- ************
- RAISE SPELLS
- ************
- raisespells(x)
raisemspells(x)
subroutine to gain maximum spells
*/
void
-raisespells(x)
- int x;
-{
- if ((c[SPELLS] += x) > c[SPELLMAX])
- c[SPELLS] = c[SPELLMAX];
-}
-
-void
-raisemspells(x)
- int x;
+raisemspells(int x)
{
c[SPELLMAX] += x;
c[SPELLS] += x;
}
/*
- ************
- LOOSE SPELLS
- ************
- losespells(x)
losemspells(x)
subroutine to lose maximum spells
*/
void
-losespells(x)
- int x;
-{
- if ((c[SPELLS] -= x) < 0)
- c[SPELLS] = 0;
-}
-
-void
-losemspells(x)
- int x;
+losemspells(int x)
{
if ((c[SPELLMAX] -= x) < 0)
c[SPELLMAX] = 0;
for the given cave level
*/
int
-makemonst(lev)
- int lev;
+makemonst(int lev)
{
int tmp, x;
if (lev < 1)
function to be sure player is not in a wall
*/
void
-positionplayer()
+positionplayer(void)
{
int try;
try = 2;
recalc() function to recalculate the armor class of the player
*/
void
-recalc()
+recalc(void)
{
int i, j, k;
c[AC] = c[MOREDEFENSES];
subroutine to ask if the player really wants to quit
*/
void
-quit()
+quit(void)
{
int i;
cursors();
function to ask --more-- then the user must enter a space
*/
void
-more()
+more(void)
{
lprcat("\n --- press ");
standout("space");
returns 1 if something there already else 0
*/
int
-drop_object(k)
- int k;
+drop_object(int k)
{
int theitem;
if ((k < 0) || (k > 25))
function to enchant armor player is currently wearing
*/
void
-enchantarmor()
+enchantarmor(void)
{
int tmp;
if (c[WEAR] < 0) {
function to enchant a weapon presently being wielded
*/
void
-enchweapon()
+enchweapon(void)
{
int tmp;
if (c[WIELD] < 0) {
returns 1 if pockets are full, else 0
*/
int
-pocketfull()
+pocketfull(void)
{
int i, limit;
if ((limit = 15 + (c[LEVEL] >> 1)) > 26)
function to return 1 if a monster is next to the player else returns 0
*/
int
-nearbymonst()
+nearbymonst(void)
{
int tmp, tmp2;
for (tmp = playerx - 1; tmp < playerx + 2; tmp++)
returns 1 if steals something else returns 0
*/
int
-stealsomething()
+stealsomething(void)
{
int i, j;
j = 100;
function to return 1 is player carrys nothing else return 0
*/
int
-emptyhanded()
+emptyhanded(void)
{
int i;
for (i = 0; i < 26; i++)
function to create a gem on a square near the player
*/
void
-creategem()
+creategem(void)
{
int i, j;
switch (rnd(4)) {
*/
static char gpwbuf[33];
int
-getpassword()
+getpassword(void)
{
int i, j;
char *gpwp;
lflush();
i = strlen(password);
for (j = 0; j < i; j++)
- read(0, gpwp++, 1);
+ *gpwp++ = ttgetch();
gpwbuf[i] = 0;
sncbr(); /* system("stty echo -cbreak"); */
if (strcmp(gpwbuf, password) != 0) {
returns y or n
*/
int
-getyn()
+getyn(void)
{
int i;
i = 0;
returns the number of pounds the player is carrying
*/
int
-packweight()
+packweight(void)
{
int i, j, k;
k = c[GOLD] / 1000;
#ifndef MACRORND
/* macros to generate random numbers 1<=rnd(N)<=N 0<=rund(N)<=N-1 */
int
-rnd(x)
- int x;
+rnd(int x)
{
return ((((randx = randx * 1103515245 + 12345) >> 7) % (x)) + 1);
}
int
-rund(x)
- int x;
+rund(int x)
{
return ((((randx = randx * 1103515245 + 12345) >> 7) % (x)));
}