Mercurial > hg > early-roguelike
annotate arogue5/rings.c @ 81:0e212d46b68f
rogue4: don't put savefile metadata into the savefile.
The save_file() function in save.c stored the savefile's device number,
inode number, creation time, and modification time in the file. The
restore() function read them back, and apparently used to compare them
to protect against cheaters.
Unfortunately, the types and sizes of these numbers differ from system
to system, which ruins the Roguelike Restoration Project's fine
portability work. So they have been removed from the savefile.
This BREAKS SAVEFILE COMPATIBILITY, but old files can be converted by
excising the chunk starting at offset 0x22 with length sizeof(ino_t) +
sizeof(dev_t) + 2 * sizeof(time_t). That's 0x14 on i686 and 0x20 on
x86_64, at least with current versions of Linux and glibc.
author | John "Elwin" Edwards |
---|---|
date | Mon, 05 Aug 2013 20:49:41 -0700 |
parents | ad2cb9a07aaa |
children | f2951c4e28d9 |
rev | line source |
---|---|
63
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
1 /* |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
2 * routines dealing specifically with rings |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
3 * |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
4 * Advanced Rogue |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
5 * Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
6 * All rights reserved. |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
7 * |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
8 * Based on "Rogue: Exploring the Dungeons of Doom" |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
9 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
10 * All rights reserved. |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
11 * |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
12 * See the file LICENSE.TXT for full copyright and licensing information. |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
13 */ |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
14 |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
15 #include "curses.h" |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
16 #include "rogue.h" |
67 | 17 #include <stdlib.h> |
18 #include <string.h> | |
63
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
19 |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
20 /* |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
21 * how much food does this ring use up? |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
22 */ |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
23 ring_eat(hand) |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
24 register int hand; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
25 { |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
26 if (cur_ring[hand] == NULL) |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
27 return 0; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
28 switch (cur_ring[hand]->o_which) { |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
29 case R_VAMPREGEN: |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
30 return 3; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
31 case R_REGEN: |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
32 return 2; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
33 case R_HEALTH: |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
34 case R_SUSABILITY: |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
35 return 1; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
36 case R_SEARCH: |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
37 case R_SEEINVIS: |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
38 return (rnd(100) < 33); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
39 case R_DIGEST: |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
40 if (cur_ring[hand]->o_ac >= 0) |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
41 return (-(cur_ring[hand]->o_ac)-1); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
42 else |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
43 return (-(cur_ring[hand]->o_ac)); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
44 } |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
45 return 0; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
46 } |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
47 |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
48 ring_on(obj) |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
49 register struct object *obj; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
50 { |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
51 register int save_max; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
52 char buf[LINELEN]; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
53 |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
54 /* |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
55 * Calculate the effect it has on the poor guy. |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
56 */ |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
57 switch (obj->o_which) |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
58 { |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
59 case R_ADDSTR: |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
60 save_max = max_stats.s_str; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
61 chg_str(obj->o_ac); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
62 max_stats.s_str = save_max; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
63 when R_ADDHIT: |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
64 pstats.s_dext += obj->o_ac; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
65 when R_ADDINTEL: |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
66 pstats.s_intel += obj->o_ac; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
67 when R_ADDWISDOM: |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
68 pstats.s_wisdom += obj->o_ac; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
69 when R_SEEINVIS: |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
70 turn_on(player, CANSEE); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
71 msg("Your eyes begin to tingle"); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
72 light(&hero); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
73 mvwaddch(cw, hero.y, hero.x, PLAYER); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
74 when R_AGGR: |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
75 aggravate(); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
76 when R_WARMTH: |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
77 turn_on(player, NOCOLD); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
78 when R_FIRE: |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
79 turn_on(player, NOFIRE); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
80 when R_LIGHT: { |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
81 if(roomin(&hero) != NULL) { |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
82 light(&hero); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
83 mvwaddch(cw, hero.y, hero.x, PLAYER); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
84 } |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
85 } |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
86 when R_SEARCH: |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
87 daemon(ring_search, 0, AFTER); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
88 when R_TELEPORT: |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
89 daemon(ring_teleport, 0, AFTER); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
90 } |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
91 status(FALSE); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
92 if (r_know[obj->o_which] && r_guess[obj->o_which]) |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
93 { |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
94 free(r_guess[obj->o_which]); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
95 r_guess[obj->o_which] = NULL; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
96 } |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
97 else if (!r_know[obj->o_which] && |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
98 askme && |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
99 (obj->o_flags & ISKNOW) == 0 && |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
100 r_guess[obj->o_which] == NULL) { |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
101 msg(terse ? "Call it: " : "What do you want to call it? "); |
76
ad2cb9a07aaa
arogue5: fix player's typed responses getting put at the wrong place.
John "Elwin" Edwards <elwin@sdf.org>
parents:
67
diff
changeset
|
102 if (get_str(buf, msgw) == NORM) |
63
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
103 { |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|