* interplayer.c - player to player routines for Phantasia
/************************************************************************
/ FUNCTION NAME: checkbattle()
/ FUNCTION: check to see if current player should battle another
/ AUTHOR: E. A. Estes, 12/4/85
/ MODULES CALLED: battleplayer(), fread(), fseek()
/ GLOBAL INPUTS: Other, Users, Player, Fileloc, *Playersfp
/ Seach player file for a foe at the same coordinates as the
/ Also update user count.
/************************************************************************/
long foeloc
= 0L; /* location in file of person to fight */
while (fread((char *) &Other
, SZ_PLAYERSTRUCT
, 1, Playersfp
) == 1)
if (Other
.p_status
!= S_OFF
&& Other
.p_status
!= S_NOTUSED
&& Other
.p_status
!= S_HUNGUP
&& (Other
.p_status
!= S_CLOAKED
|| Other
.p_specialtype
!= SC_VALAR
))
/* player is on and not a cloaked valar */
if (Player
.p_x
== Other
.p_x
&& Player
.p_y
== Other
.p_y
&& Player
.p_status
== S_PLAYING
&& (Other
.p_status
== S_PLAYING
|| Other
.p_status
== S_INBATTLE
)
&& Other
.p_specialtype
!= SC_VALAR
&& Player
.p_specialtype
!= SC_VALAR
)
foeloc
+= SZ_PLAYERSTRUCT
;
/************************************************************************
/ FUNCTION NAME: battleplayer()
/ FUNCTION: inter-terminal battle with another player
/ AUTHOR: E. A. Estes, 2/15/86
/ long foeplace - location in player file of person to battle
/ MODULES CALLED: readrecord(), readmessage(), writerecord(), collecttaxes(),
/ displaystats(), fabs(), more(), death(), sleep(), wmove(), waddch(), printw(),
/ myturn(), altercoordinates(), waddstr(), wrefresh(), mvprintw(),
/ getanswer(), wclrtoeol(), wclrtobot()
/ GLOBAL INPUTS: Foestrikes, LINES, Lines, Other, Shield, Player, *stdscr,
/ GLOBAL OUTPUTS: Foestrikes, Lines, Shield, Player, Luckout, *Enemyname
/ Inter-terminal battle is a very fragile and slightly klugy thing.
/ At any time, one player is master and the other is slave.
/ We pick who is master first by speed and level. After that,
/ the slave waits for the master to relinquish its turn, and
/ the slave becomes master, and so on.
/ The items in the player structure which control the handshake are:
/ master increments this to relinquish control
/ master sets this to specify particular action
/ set to total damage inflicted so far; changes to indicate action
/************************************************************************/
double dtemp
; /* for temporary calculations */
double oldhits
= 0.0; /* previous damage inflicted by foe */
register int loop
; /* for timing out */
short oldtampered
; /* old value of foe's p_tampered */
mvaddstr(4, 0, "Preparing for battle!\n");
/* set up variables, file, etc. */
Player
.p_status
= S_INBATTLE
;
Shield
= Player
.p_energy
;
/* if p_tampered is not 0, someone else may try to change it (king, etc.) */
Player
.p_tampered
= oldtampered
= 1;
readrecord(&Other
, foeplace
);
if (fabs(Player
.p_level
- Other
.p_level
) > 20.0)
/* see if players are greatly mismatched */
dtemp
= (Player
.p_level
- Other
.p_level
) / MAX(Player
.p_level
, Other
.p_level
);
/* foe outweighs this one */
writerecord(&Player
, Fileloc
); /* write out all our info */
Enemyname
= Other
.p_name
;
mvprintw(6, 0, "You have encountered %s Level: %.0f\n", Enemyname
, Other
.p_level
);
for (loop
= 0; Other
.p_status
!= S_INBATTLE
&& loop
< 30; ++loop
)
/* wait for foe to respond */
readrecord(&Other
, foeplace
);
if (Other
.p_status
!= S_INBATTLE
)
/* foe did not respond */
mvprintw(5, 0, "%s is not responding.\n", Enemyname
);
/* else, we are ready to battle */
* determine who is first master
* if neither player is faster, check level
* if neither level is greater, battle is not allowed
* (this should never happen, but we have to handle it)
if (Player
.p_speed
> Other
.p_speed
)
else if (Other
.p_speed
> Player
.p_speed
)
else if (Player
.p_level
> Other
.p_level
)
else if (Other
.p_level
> Player
.p_level
)
printw("You can't fight %s yet.", Enemyname
);
mvprintw(1, 26, "%20.0f", Shield
); /* overprint energy */
/* take action against foe */
/* wait for foe to take action */
mvaddstr(4, 0, "Waiting...\n");
for (loop
= 0; loop
< 20; ++loop
)
/* wait for foe to act */
readrecord(&Other
, foeplace
);
if (Other
.p_1scratch
!= oldhits
)
/* p_1scratch changes to indicate action */
if (Other
.p_1scratch
== oldhits
)
mvaddstr(22, 0, "Timeout: waiting for response. Do you want to wait ? ");
ch
= getanswer("NY", FALSE
);
case I_RAN
: /* foe ran away */
mvprintw(Lines
++, 0, "%s ran away!", Enemyname
);
case I_STUCK
: /* foe tried to run, but couldn't */
mvprintw(Lines
++, 0, "%s tried to run away.", Enemyname
);
case I_BLEWIT
: /* foe tried to luckout, but didn't */
mvprintw(Lines
++, 0, "%s tried to luckout!", Enemyname
);
dtemp
= Other
.p_1scratch
- oldhits
;
mvprintw(Lines
++, 0, "%s hit you %.0f times!", Enemyname
, dtemp
);
oldhits
= Other
.p_1scratch
; /* keep track of old hits */
if (Other
.p_tampered
!= oldtampered
)
/* p_tampered changes to relinquish turn */
oldtampered
= Other
.p_tampered
;
/* decide what happens next */
if (Other
.p_istat
== I_KILLED
|| Shield
< 0.0)
Shield
= -2.0; /* insure this value is negative */
if (Player
.p_istat
== I_KILLED
)
/* we killed foe; award treasre */
mvprintw(Lines
++, 0, "You killed %s!", Enemyname
);
Player
.p_experience
+= Other
.p_experience
;
Player
.p_crowns
+= (Player
.p_level
< 1000.0) ? Other
.p_crowns
: 0;
Player
.p_amulets
+= Other
.p_amulets
;
Player
.p_charms
+= Other
.p_charms
;
collecttaxes(Other
.p_gold
, Other
.p_gems
);
Player
.p_sword
= MAX(Player
.p_sword
, Other
.p_sword
);
Player
.p_shield
= MAX(Player
.p_shield
, Other
.p_shield
);
Player
.p_quksilver
= MAX(Player
.p_quksilver
, Other
.p_quksilver
);
if (Other
.p_virgin
&& !Player
.p_virgin
)
mvaddstr(Lines
++, 0, "You have rescued a virgin. Will you be honorable ? ");
if ((ch
= getanswer("YN", FALSE
)) == 'Y')
Player
.p_experience
+= 8000.0;
sleep(3); /* give other person time to die */
else if (Player
.p_istat
== I_RAN
|| Other
.p_istat
== I_RAN
)
/* either player ran away */
/* clean up things and leave */
writerecord(&Player
, Fileloc
); /* update a final time */
altercoordinates(0.0, 0.0, A_NEAR
); /* move away from battle site */
Player
.p_energy
= Shield
; /* set energy to actual value */
Player
.p_tampered
= T_OFF
; /* clear p_tampered */
clrtobot(); /* clear bottom area of screen */
if (Player
.p_energy
< 0.0)
death("Interterminal battle");
/************************************************************************
/ FUNCTION NAME: myturn()
/ FUNCTION: process players action against foe in battle
/ AUTHOR: E. A. Estes, 2/7/86
/ MODULES CALLED: writerecord(), inputoption(), floor(), wmove(), drandom(),
/ waddstr(), wrefresh(), mvprintw(), wclrtoeol(), wclrtobot()
/ GLOBAL INPUTS: Lines, Other, Player, *stdscr, Fileloc, Luckout,
/ GLOBAL OUTPUTS: Foestrikes, Lines, Player, Luckout
/ Take action action against foe, and decide who is master
/************************************************************************/
double dtemp
; /* for temporary calculations */
mvaddstr(7, 0, "1:Fight 2:Run Away! 3:Power Blast ");
dtemp
= ROLL(2.0, Player
.p_might
);
mvprintw(Lines
++, 0, "You hit %s %.0f times!", Enemyname
, dtemp
);
Player
.p_1scratch
+= dtemp
;
Player
.p_1scratch
-= 1.0; /* change this to indicate action */
mvaddstr(Lines
++, 0, "You got away!");
mvprintw(Lines
++, 0, "%s is still after you!", Enemyname
);
Player
.p_istat
= I_STUCK
;
case '3': /* power blast */
dtemp
= MIN(Player
.p_mana
, Player
.p_level
* 5.0);
dtemp
*= (drandom() + 0.5) * Player
.p_magiclvl
* 0.2 + 2.0;
mvprintw(Lines
++, 0, "You blasted %s !", Enemyname
);
if (Luckout
|| drandom() > 0.1)
mvaddstr(Lines
++, 0, "You already tried that!");
mvaddstr(Lines
++, 0, "Not this time . . .");
Player
.p_1scratch
-= 1.0;
Player
.p_istat
= I_BLEWIT
;
mvaddstr(Lines
++, 0, "You just lucked out!");
Player
.p_1scratch
= Other
.p_energy
* 1.1;
Player
.p_1scratch
= floor(Player
.p_1scratch
); /* clean up any mess */
if (Player
.p_1scratch
> Other
.p_energy
)
Player
.p_istat
= I_KILLED
;
else if (drandom() * Player
.p_speed
< drandom() * Other
.p_speed
)
writerecord(&Player
, Fileloc
); /* let foe know what we did */
/************************************************************************
/ FUNCTION NAME: checktampered()
/ FUNCTION: check if current player has been tampered with
/ AUTHOR: E. A. Estes, 12/4/85
/ MODULES CALLED: readrecord(), fread(), fseek(), tampered(), writevoid()
/ GLOBAL INPUTS: *Energyvoidfp, Other, Player, Fileloc, Enrgyvoid
/ GLOBAL OUTPUTS: Enrgyvoid
/ Check for energy voids, holy grail, and tampering by other
/************************************************************************/
long loc
= 0L; /* location in energy void file */
/* first check for energy voids */
fseek(Energyvoidfp
, 0L, 0);
while (fread((char *) &Enrgyvoid
, SZ_VOIDSTRUCT
, 1, Energyvoidfp
) == 1)
&& Enrgyvoid
.ev_x
== Player
.p_x
&& Enrgyvoid
.ev_y
== Player
.p_y
)
/* not the holy grail; inactivate energy void */
Enrgyvoid
.ev_active
= FALSE
;
writevoid(&Enrgyvoid
, loc
);
tampered(T_NRGVOID
, 0.0, 0.0);
else if (Player
.p_status
!= S_CLOAKED
)
tampered(T_GRAIL
, 0.0, 0.0);
/* now check for other things */
readrecord(&Other
, Fileloc
);
if (Other
.p_tampered
!= T_OFF
)
tampered(Other
.p_tampered
, Other
.p_1scratch
, Other
.p_2scratch
);
/************************************************************************
/ FUNCTION NAME: tampered()
/ FUNCTION: take care of tampering by other players
/ AUTHOR: E. A. Estes, 12/4/85
/ int what - what type of tampering
/ double arg1, arg2 - rest of tampering info
/ MODULES CALLED: writerecord(), more(), fread(), death(), fseek(), sleep(),
/ floor(), wmove(), waddch(), drandom(), printw(), altercoordinates(),
/ waddstr(), wrefresh(), encounter(), writevoid()
/ GLOBAL INPUTS: Other, Player, *stdscr, Enrgyvoid, *Playersfp
/ GLOBAL OUTPUTS: Other, Player, Changed, Enrgyvoid
/ Take care of energy voids, holy grail, decree and intervention
/ action on current player.
/************************************************************************/
tampered(what
, arg1
, arg2
)
long loc
; /* location in file of other players */
Player
.p_tampered
= T_OFF
; /* no longer tampered with */
addstr("You've hit an energy void !\n");
Player
.p_gold
= floor(Player
.p_gold
/1.25) + 0.1;
altercoordinates(0.0, 0.0, A_NEAR
);
addstr("The king transported you ! ");
addstr("But your charm saved you. . .\n");
altercoordinates(0.0, 0.0, A_FAR
);
printw("The king has bestowed %.0f gold pieces on you !\n", arg1
);
addstr("You've been cursed ! ");
addstr("But your blessing saved you. . .\n");
Player
.p_blessing
= FALSE
;
Player
.p_maxenergy
*= 0.95;
Player
.p_status
= S_PLAYING
; /* no longer cloaked */
addstr("You have been vaporized!\n");
addstr("The Valar zapped you with a monster!\n");
addstr("The Valar has blessed you!\n");
Player
.p_energy
= (Player
.p_maxenergy
*= 1.05) + Player
.p_shield
;
Player
.p_strength
+= 0.5;
Player
.p_magiclvl
+= 0.5;
Player
.p_poison
= MIN(0.5, Player
.p_poison
);
addstr("You've been relocated. . .\n");
altercoordinates(arg1
, arg2
, A_FORCED
);
addstr("You've been healed!\n");
Player
.p_energy
= Player
.p_maxenergy
+ Player
.p_shield
;
addstr("You are no longer Valar!\n");
Player
.p_specialtype
= SC_COUNCIL
;
addstr("You have found The Holy Grail!!\n");
if (Player
.p_specialtype
< SC_COUNCIL
)
/* must be council of wise to behold grail */
addstr("However, you are not experienced enough to behold it.\n");
Player
.p_sin
*= Player
.p_sin
;
else if (Player
.p_specialtype
== SC_VALAR
|| Player
.p_specialtype
== SC_EXVALAR
)
addstr("You have made it to the position of Valar once already.\n");
addstr("The Grail is of no more use to you now.\n");
addstr("It is now time to see if you are worthy to behold it. . .\n");
if (drandom() / 2.0 < Player
.p_sin
)
addstr("You have failed!\n");
Player
.p_quickness
= 1.0;
altercoordinates(1.0, 1.0, A_FORCED
);
addstr("You made to position of Valar!\n");
Player
.p_specialtype
= SC_VALAR
;
while (fread((char *) &Other
, SZ_PLAYERSTRUCT
, 1, Playersfp
) == 1)
/* search for existing valar */
if (Other
.p_specialtype
== SC_VALAR
&& Other
.p_status
!= S_NOTUSED
)
Other
.p_tampered
= T_EXVALAR
;
writerecord(&Other
, loc
);
/* move grail to new location */
Enrgyvoid
.ev_active
= TRUE
;
Enrgyvoid
.ev_x
= ROLL(-1.0e6
, 2.0e6
);
Enrgyvoid
.ev_y
= ROLL(-1.0e6
, 2.0e6
);
writevoid(&Enrgyvoid
, 0L);
/************************************************************************
/ FUNCTION NAME: userlist()
/ FUNCTION: print list of players and locations
/ AUTHOR: E. A. Estes, 2/28/86
/ bool ingameflag - set if called while playing
/ MODULES CALLED: descrstatus(), descrlocation(), more(), fread(), fseek(),
/ floor(), wmove(), printw(), waddstr(), distance(), wrefresh(),
/ descrtype(), wclrtobot()
/ GLOBAL INPUTS: LINES, Other, Circle, Wizard, Player, *stdscr, *Playersfp
/ We can only see the coordinate of those closer to the origin
/ Kings and council of the wise can see and can be seen by everyone.
/ Palantirs are good for seeing everyone; and the valar can use
/ one to see through a 'cloak' spell.
/ The valar has no coordinates, and is completely invisible if
/************************************************************************/
register int numusers
= 0; /* number of users on file */
if (ingameflag
&& Player
.p_blindness
)
mvaddstr(8, 0, "You cannot see anyone.\n");
"Name X Y Lvl Type Login Status\n");
while (fread((char *) &Other
, SZ_PLAYERSTRUCT
, 1, Playersfp
) == 1)
if (Other
.p_status
== S_NOTUSED
|| (Other
.p_specialtype
== SC_VALAR
&& Other
.p_status
== S_CLOAKED
))
/* wizard can see everything on file */
/* must be playing for the rest of these conditions */
(Player
.p_specialtype
>= SC_KING
/* kings and higher can see others */
|| Other
.p_specialtype
>= SC_KING
/* kings and higher can be seen by others */
|| Circle
>= CIRCLE(Other
.p_x
, Other
.p_y
)
/* those nearer the origin can be seen */
/* palantir enables one to see others */
&& (Other
.p_status
!= S_CLOAKED
|| (Player
.p_specialtype
== SC_VALAR
&& Player
.p_palantir
))
/* not cloaked; valar can see through cloak with a palantir */
&& Other
.p_specialtype
!= SC_VALAR
)
/* coordinates should be printed */
printw("%-20s %8.0f %8.0f ",
Other
.p_name
, Other
.p_x
, Other
.p_y
);
/* cannot see player's coordinates */
Other
.p_name
, descrlocation(&Other
, TRUE
));
printw("%6.0f %s %-9.9s%s\n", Other
.p_level
, descrtype(&Other
, TRUE
),
Other
.p_login
, descrstatus(&Other
));
if ((numusers
% (LINES
- 10)) == 0)
printw("Total players on file = %d\n", numusers
);
/************************************************************************
/ FUNCTION NAME: throneroom()
/ FUNCTION: king stuff upon entering throne
/ AUTHOR: E. A. Estes, 12/16/85
/ MODULES CALLED: writerecord(), fread(), fseek(), fopen(), wmove(), fclose(),
/ fwrite(), altercoordinates(), waddstr(), fprintf()
/ GLOBAL INPUTS: *Energyvoidfp, Other, Player, *stdscr, Voidfile[],
/ Messfile[], Enrgyvoid, *Playersfp
/ GLOBAL OUTPUTS: Other, Player, Changed
/ If player is not already king, make him/her so if the old king
/ Clear energy voids with new king.
/************************************************************************/
FILE *fp
; /* to clear energy voids */
long loc
= 0L; /* location of old king in player file */
if (Player
.p_specialtype
< SC_KING
)
/* not already king -- assumes crown */
while (fread((char *) &Other
, SZ_PLAYERSTRUCT
, 1, Playersfp
) == 1)
if (Other
.p_specialtype
== SC_KING
&& Other
.p_status
!= S_NOTUSED
)
if (Other
.p_status
!= S_OFF
)
/* old king is playing */
mvaddstr( 4, 0, "The king is playing, so you cannot steal his throne\n");
altercoordinates(0.0, 0.0, A_NEAR
);
/* old king is not playing - remove him/her */
Other
.p_specialtype
= SC_NONE
;
writerecord(&Other
, loc
);
/* make player new king */
Player
.p_specialtype
= SC_KING
;
mvaddstr(4, 0, "You have become king!\n");
/* let everyone else know */
fp
= fopen(Messfile
, "w");
fprintf(fp
, "All hail the new king!");
/* clear all energy voids; retain location of holy grail */
fseek(Energyvoidfp
, 0L, 0);
fread((char *) &Enrgyvoid
, SZ_VOIDSTRUCT
, 1, Energyvoidfp
);
fp
= fopen(Voidfile
, "w");
fwrite((char *) &Enrgyvoid
, SZ_VOIDSTRUCT
, 1, fp
);
mvaddstr(6, 0, "0:Decree ");
/************************************************************************
/ FUNCTION NAME: dotampered()
/ FUNCTION: king and valar special options
/ AUTHOR: E. A. Estes, 2/28/86
/ MODULES CALLED: writerecord(), truncstring(), fread(), fseek(), fopen(),
/ floor(), wmove(), drandom(), fclose(), fwrite(), sscanf(), strcmp(),
/ infloat(), waddstr(), findname(), distance(), userlist(), mvprintw(),
/ allocvoid(), getanswer(), getstring(), wclrtoeol(), writevoid()
/ GLOBAL INPUTS: *Energyvoidfp, Other, Illcmd[], Wizard, Player, *stdscr,
/ Databuf[], Goldfile[], Enrgyvoid
/ GLOBAL OUTPUTS: Other, Player, Enrgyvoid
/ Tamper with other players. Handle king/valar specific options.
/************************************************************************/
short tamper
; /* value for tampering with other players */
char *option
; /* pointer to option description */
double temp1
= 0.0, temp2
= 0.0; /* other tampering values */
long loc
; /* location in energy void file */
FILE *fp
; /* for opening gold file */
if (Player
.p_specialtype
< SC_COUNCIL
&& !Wizard
)
addstr("1:Transport 2:Curse 3:Energy Void 4:Bestow 5:Collect Taxes ");
ch
= getanswer(" ", TRUE
);
case '1': /* transport someone */
case '2': /* curse another */
case '3': /* create energy void */
if ((loc
= allocvoid()) > 20L * SZ_VOIDSTRUCT
)
/* can only have 20 void active at once */
mvaddstr(5, 0, "Sorry, void creation limit reached.\n");
addstr("Enter the X Y coordinates of void ? ");
getstring(Databuf
, SZ_DATABUF
);
sscanf(Databuf
, "%F %F", &temp1
, &temp2
);
Enrgyvoid
.ev_x
= floor(temp1
);
Enrgyvoid
.ev_y
= floor(temp2
);
Enrgyvoid
.ev_active
= TRUE
;
writevoid(&Enrgyvoid
, loc
);
mvaddstr(5, 0, "It is done.\n");
case '4': /* bestow gold to subject */
addstr("How much gold to bestow ? ");
if (temp1
> Player
.p_gold
|| temp1
< 0)
mvaddstr(5, 0, "You don't have that !\n");
/* adjust gold after we are sure it will be given to someone */
case '5': /* collect accumulated taxes */
if ((fp
= fopen(Goldfile
, "r+")) != NULL
)
fread((char *) &temp1
, sizeof(double), 1, fp
);
fwrite((char *) &temp2
, sizeof(double), 1, fp
);
mvprintw(4, 0, "You have collected %.0f in gold.\n", temp1
);
Player
.p_gold
+= floor(temp1
);
/* end of king options */
/* council of wise, valar, wizard options */
if (Player
.p_palantir
|| Wizard
)
if (Player
.p_specialtype
== SC_VALAR
|| Wizard
)
addstr("3:Throw Monster 4:Relocate 5:Bless ");
ch
= getanswer(" ", TRUE
);
if (ch
> '2' && Player
.p_specialtype
!= SC_VALAR
)
if (Player
.p_mana
< MM_INTERVENE
)
mvaddstr(5, 0, "No mana left.\n");
Player
.p_mana
-= MM_INTERVENE
;
case '1': /* heal another */
case '2': /* seek grail */
/* need a palantir to seek */
fseek(Energyvoidfp
, 0L, 0);
fread((char *) &Enrgyvoid
, SZ_VOIDSTRUCT
, 1, Energyvoidfp
);
temp1
= distance(Player
.p_x
, Enrgyvoid
.ev_x
, Player
.p_y
, Enrgyvoid
.ev_y
);
temp1
+= ROLL(-temp1
/ 10.0, temp1
/ 5.0); /* add some error */
mvprintw(5, 0, "The palantir says the Grail is about %.0f away.\n", temp1
);
mvaddstr(5, 0, "You need a palantir to seek the Grail.\n");
case '3': /* lob monster at someone */
mvaddstr(4, 0, "Which monster [0-99] ? ");
temp1
= MAX(0.0, MIN(99.0, temp1
));
option
= "throw a monster at";
case '4': /* move another player */
mvaddstr(4, 0, "New X Y coordinates ? ");
getstring(Databuf
, SZ_DATABUF
);
sscanf(Databuf
, "%F %F", &temp1
, &temp2
);
case '5': /* bless a player */
case '6': /* kill off a player */
/* adjust age after we are sure intervention will be done */
/* end of valar, etc. options */
/* prompt for player to affect */
mvprintw(4, 0, "Who do you want to %s ? ", option
);
getstring(Databuf
, SZ_DATABUF
);
if (strcmp(Player
.p_name
, Databuf
) != 0)
/* name other than self */
if ((loc
= findname(Databuf
, &Other
)) >= 0L)
if (Other
.p_tampered
!= T_OFF
)
mvaddstr(5, 0, "That person has something pending already.\n");
&& CIRCLE(temp1
, temp2
) < CIRCLE(Other
.p_x
, Other
.p_y
)
mvaddstr(5, 0, "Cannot move someone closer to the Lord's Chamber.\n");
if (tamper
== T_BESTOW
) Player
.p_gold
-= floor(temp1
);
if (!Wizard
&& (tamper
== T_HEAL
|| tamper
== T_MONSTER
||
tamper
== T_RELOCATE
|| tamper
== T_BLESSED
))
Player
.p_age
+= N_AGE
; /* age penalty */
Other
.p_tampered
= tamper
;
Other
.p_1scratch
= floor(temp1
);
Other
.p_2scratch
= floor(temp2
);
writerecord(&Other
, loc
);
mvaddstr(5, 0, "It is done.\n");
mvaddstr(5, 0, "There is no one by that name.\n");
mvaddstr(5, 0, "You may not do it to yourself!\n");
/************************************************************************
/ FUNCTION NAME: writevoid()
/ FUNCTION: update energy void entry in energy void file
/ AUTHOR: E. A. Estes, 12/4/85
/ struct energyvoid *vp - pointer to structure to write to file
/ long loc - location in file to update
/ MODULES CALLED: fseek(), fwrite(), fflush()
/ GLOBAL INPUTS: *Energyvoidfp
/ Write out energy void structure at specified location.
/************************************************************************/
register struct energyvoid
*vp
;
fseek(Energyvoidfp
, loc
, 0);
fwrite((char *) vp
, SZ_VOIDSTRUCT
, 1, Energyvoidfp
);
fseek(Energyvoidfp
, 0L, 0);
/************************************************************************
/ FUNCTION NAME: allocvoid()
/ FUNCTION: allocate space for a new energy void
/ AUTHOR: E. A. Estes, 12/4/85
/ RETURN VALUE: location of new energy void space
/ MODULES CALLED: fread(), fseek()
/ GLOBAL INPUTS: *Energyvoidfp, Enrgyvoid
/ Search energy void file for an inactive entry and return its
/ If no inactive ones are found, return one more than last location.
/************************************************************************/
long loc
= 0L; /* location of new energy void */
fseek(Energyvoidfp
, 0L, 0);
while (fread((char *) &Enrgyvoid
, SZ_VOIDSTRUCT
, 1, Energyvoidfp
) == 1)