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

Comparing deliantra/server/server/freezethaw.C (file contents):
Revision 1.25 by root, Tue Sep 4 05:43:22 2007 UTC vs.
Revision 1.36 by root, Fri Mar 26 01:04:45 2010 UTC

1/* 1/*
2 * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team 4 * Copyright (©) 2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * 5 *
6 * Crossfire TRT is free software: you can redistribute it and/or modify 6 * Deliantra is free software: you can redistribute it and/or modify it under
7 * it under the terms of the GNU General Public License as published by 7 * the terms of the Affero GNU General Public License as published by the
8 * the Free Software Foundation, either version 3 of the License, or 8 * Free Software Foundation, either version 3 of the License, or (at your
9 * (at your option) any later version. 9 * option) any later version.
10 * 10 *
11 * This program is distributed in the hope that it will be useful, 11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License 16 * You should have received a copy of the Affero GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * and the GNU General Public License along with this program. If not, see
18 * <http://www.gnu.org/licenses/>.
18 * 19 *
19 * The authors can be reached via e-mail to <crossfire@schmorp.de> 20 * The authors can be reached via e-mail to <support@deliantra.net>
20 */ 21 */
21 22
22#include "global.h" // bug in cfperl.h, doesn't include interface_class stuff 23#include "global.h" // bug in cfperl.h, doesn't include interface_class stuff
23#include "logger.h" 24#include "logger.h"
24#include "cfperl.h" 25#include "cfperl.h"
34{ 35{
35 SvREFCNT_dec (av); 36 SvREFCNT_dec (av);
36} 37}
37 38
38void 39void
39object_freezer::put (attachable *ext) 40object_freezer::put_ (attachable *ext)
40{ 41{
41 ext->optimise (); 42 ext->optimise ();
42 43
43 if (ext->self) 44 if (ext->self)
44 { 45 {
45 int idx = AvFILLp ((AV *)av) + 1; 46 int idx = AvFILLp ((AV *)av) + 1;
46 av_store (av, idx, newRV_inc ((SV *)ext->self)); 47 av_store (av, idx, newRV_inc ((SV *)ext->self));
47 48
48 add ((void *)"oid ", 4); 49 put (KW(oid), sint32(idx));
49 add ((sint32)idx);
50 add ('\n');
51 } 50 }
52} 51}
53 52
54bool 53bool
55object_freezer::save (const char *path) 54object_freezer::save (const char *path)
108static const char thawer_eof[] = "\n\n\n\0\0\0"; 107static const char thawer_eof[] = "\n\n\n\0\0\0";
109 108
110object_thawer::object_thawer (const char *path) 109object_thawer::object_thawer (const char *path)
111: name (strdup (path)) 110: name (strdup (path))
112{ 111{
113 static const char eof[] = "\n\n\n\0\0\0";
114
115 av = 0; 112 av = 0;
116 text = 0; 113 text = 0;
117 line = 0; 114 line = 0;
118 linenum = 0; 115 linenum = 0;
119 116
139 // first value - text part, pad with 3 zeroes 136 // first value - text part, pad with 3 zeroes
140 { 137 {
141 SV *sv = POPs; 138 SV *sv = POPs;
142 STRLEN len; 139 STRLEN len;
143 char *sv_ = SvPVbyte (sv, len); 140 char *sv_ = SvPVbyte (sv, len);
144 text = newSV (len + sizeof (eof)); 141 text = newSV (len + sizeof (thawer_eof));
145 SvCUR_set (text, len); 142 SvCUR_set (text, len + sizeof (thawer_eof));
146 memcpy (SvPVX (text), sv_, len); 143 memcpy (SvPVX (text), sv_, len);
147 memcpy (SvEND (text), eof, sizeof (eof)); // just to be sure 144 memcpy (SvPVX (text) + len, thawer_eof, sizeof (thawer_eof));
148 145
149 line = SvPVX (text); 146 line = SvPVX (text);
150 next (); 147 next ();
151 } 148 }
152 } 149 }
389} 386}
390 387
391void 388void
392object_thawer::skip_block () 389object_thawer::skip_block ()
393{ 390{
394 while (kw != KW_ERROR && kw != KW_EOF) 391 // must not stop at KW_ERROR, as those signify custom keys
392 while (kw != KW_EOF)
395 { 393 {
396 keyword w = kw; 394 keyword w = kw;
397 skip (); 395 skip ();
396
397 if (0 && (w == KW_map || w == KW_arch || w == KW_object || w == KW_region))
398 skip_block ();
398 if (w == KW_end) 399 else if (w == KW_end)
399 break; 400 break;
400 } 401 }
401} 402}
402 403
403void 404void
452} 453}
453 454
454sint32 455sint32
455object_thawer::get_sint32 () const 456object_thawer::get_sint32 () const
456{ 457{
457 char *p = value_nn; 458 const char *p = value_nn;
458 459
459 sint32 val = 0; 460 sint32 val = 0;
460 bool negate; 461 bool negate;
461 462
462 if (*p == '-') 463 if (*p == '-')

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines