ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/resurrection.C
(Generate patch)

Comparing deliantra/server/server/resurrection.C (file contents):
Revision 1.37 by root, Sat Apr 23 04:56:57 2011 UTC vs.
Revision 1.45 by root, Wed Jun 26 06:52:41 2019 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team
4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 5 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team 6 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992 Frank Tore Johansen 7 * Copyright (©) 1992 Frank Tore Johansen
7 * 8 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 9 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the 10 * the terms of the Affero GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your 11 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version. 12 * option) any later version.
12 * 13 *
13 * This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 17 * GNU General Public License for more details.
17 * 18 *
18 * You should have received a copy of the Affero GNU General Public License 19 * You should have received a copy of the Affero GNU General Public License
19 * and the GNU General Public License along with this program. If not, see 20 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>. 21 * <http://www.gnu.org/licenses/>.
21 * 22 *
22 * The authors can be reached via e-mail to <support@deliantra.net> 23 * The authors can be reached via e-mail to <support@deliantra.net>
23 */ 24 */
24 25
25/* the contents of this file were create solely by peterm@soda.berkeley.edu 26/* the contents of this file were create solely by peterm@soda.berkeley.edu
26 all of the above disclaimers apply. */ 27 all of the above disclaimers apply. */
29#include <sproto.h> 30#include <sproto.h>
30#include <spells.h> 31#include <spells.h>
31#include <errno.h> 32#include <errno.h>
32 33
33/* name of the person to resurrect and which spell was used 34/* name of the person to resurrect and which spell was used
34 * to resurrect 35 * to resurrect
35 */ 36 */
36static int 37static int
37resurrect_player (object *op, char *playername, object *spell) 38resurrect_player (object *op, char *playername, object *spell)
38{ 39{
39 FILE *deadplayer, *liveplayer; 40 FILE *deadplayer, *liveplayer;
40 41
41 char oldname[MAX_BUF]; 42 char oldname[MAX_BUF];
42 char newname[MAX_BUF]; 43 char newname[MAX_BUF];
43 char path[MAX_BUF]; 44 char path[8192];
44 char buf[MAX_BUF]; 45 char buf[MAX_BUF];
45 char buf2[MAX_BUF]; 46 char buf2[MAX_BUF];
46 const char *race = NULL; 47 const char *race = NULL;
47 sint64 exp; 48 sint64 exp;
48 int Con; 49 int Con;
77 78
78 race = t->item->archname; 79 race = t->item->archname;
79 } 80 }
80 81
81 /* set up our paths/strings... */ 82 /* set up our paths/strings... */
82 sprintf (path, "%s/%s/%s/%s", settings.localdir, settings.playerdir, playername, playername); 83 snprintf (path, sizeof (path), "%s/%s/%s/%s", settings.localdir, settings.playerdir, playername, playername);
83 84
84 strcpy (newname, path); 85 strcpy (newname, path);
85 strcat (newname, ".pl"); 86 strcat (newname, ".pl");
86 87
87 strcpy (oldname, newname); 88 strcpy (oldname, newname);
109 } 110 }
110 111
111 while (!feof (deadplayer)) 112 while (!feof (deadplayer))
112 { 113 {
113 fgets (buf, 255, deadplayer); 114 fgets (buf, 255, deadplayer);
114 sscanf (buf, "%s", buf2); 115 sscanf (buf, "%255s", buf2);
115 if (!(strcmp (buf2, "exp"))) 116 if (!(strcmp (buf2, "exp")))
116 { 117 {
117 sscanf (buf, "%s %" SCNd64, buf2, &exp); 118 sscanf (buf, "%255s %" SCNd64, buf2, &exp);
118 if (spell->stats.exp) 119 if (spell->stats.exp)
119 { 120 {
120 exp -= exp / spell->stats.exp; 121 exp -= exp / spell->stats.exp;
121 sprintf (buf, "exp %" PRId64 "\n", exp); 122 sprintf (buf, "exp %" PRId64 "\n", exp);
122 } 123 }
123 } 124 }
124 if (!(strcmp (buf2, "Con"))) 125 if (!(strcmp (buf2, "Con")))
125 { 126 {
126 sscanf (buf, "%s %d", buf2, &Con); 127 sscanf (buf, "%255s %d", buf2, &Con);
127 Con -= spell->stats.Con; 128 Con -= spell->stats.Con;
128 if (Con < 1) 129 if (Con < 1)
129 Con = 1; 130 Con = 1;
130 sprintf (buf, "Con %d\n", Con); 131 sprintf (buf, "Con %d\n", Con);
131 } 132 }
161} 162}
162 163
163 164
164/* raise_dead by peterm and mehlhaff@soda.berkeley.edu 165/* raise_dead by peterm and mehlhaff@soda.berkeley.edu
165 * op -- who is doing the resurrecting 166 * op -- who is doing the resurrecting
166 * spell - spell object 167 * spell - spell object
167 * dir -- direction the spell is cast 168 * dir -- direction the spell is cast
168 * corpseobj - corpse to raise - can be null, in which case this function will find it 169 * corpseobj - corpse to raise - can be null, in which case this function will find it
169 */ 170 */
170int 171int
171cast_raise_dead_spell (object *op, object *caster, object *spell, int dir, const char *arg) 172cast_raise_dead_spell (object *op, object *caster, object *spell, int dir, const char *arg)
188 strcpy (name_to_resurrect, arg); 189 strcpy (name_to_resurrect, arg);
189 temp = NULL; 190 temp = NULL;
190 } 191 }
191 else 192 else
192 { 193 {
193 sx = op->x + freearr_x[dir]; 194 sx = op->x + DIRX (dir);
194 sy = op->y + freearr_y[dir]; 195 sy = op->y + DIRY (dir);
195 m = op->map; 196 m = op->map;
196 mflags = get_map_flags (m, &m, sx, sy, &sx, &sy); 197 mflags = get_map_flags (m, &m, sx, sy, &sx, &sy);
197 if (mflags & P_OUT_OF_MAP) 198 if (mflags & P_OUT_OF_MAP)
198 temp = NULL; 199 temp = NULL;
199 else 200 else

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines