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.20 by root, Sun May 27 23:14:37 2007 UTC vs.
Revision 1.25 by root, Tue Sep 4 05:43:22 2007 UTC

1/*****************************************************************************/
2/* CrossFire, A roguelike realtime multiplayer game */
3/*****************************************************************************/
4
5/* 1/*
6 * This code is placed under the GNU General Public Licence (GPL) 2 * This file is part of Crossfire TRT, the Roguelike Realtime MORPG.
7 * 3 *
8 * Copyright (C) 2006 by Marc Lehmann <crossfire@schmorp.de> 4 * Copyright (©) 2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
9 * 5 *
10 * This program is free software; you can redistribute it and/or modify 6 * Crossfire TRT is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or 8 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version. 9 * (at your option) any later version.
14 * 10 *
15 * 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,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 14 * GNU General Public License for more details.
19 * 15 *
20 * You should have received a copy of the GNU General Public License 16 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software 17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 * Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 *
19 * The authors can be reached via e-mail to <crossfire@schmorp.de>
23 */ 20 */
24 21
25#include "global.h" // bug in cfperl.h, doesn't include interface_class stuff 22#include "global.h" // bug in cfperl.h, doesn't include interface_class stuff
26#include "logger.h" 23#include "logger.h"
27#include "cfperl.h" 24#include "cfperl.h"
148 SvCUR_set (text, len); 145 SvCUR_set (text, len);
149 memcpy (SvPVX (text), sv_, len); 146 memcpy (SvPVX (text), sv_, len);
150 memcpy (SvEND (text), eof, sizeof (eof)); // just to be sure 147 memcpy (SvEND (text), eof, sizeof (eof)); // just to be sure
151 148
152 line = SvPVX (text); 149 line = SvPVX (text);
150 next ();
153 } 151 }
154 } 152 }
155 153
156 CALL_END; 154 CALL_END;
157 } 155 }
158} 156}
159 157
160object_thawer::object_thawer (const char *data, AV *perlav) 158object_thawer::object_thawer (const char *data, AV *perlav)
161: name (strdup ("(memory stream")) 159: name (strdup ("(memory stream)"))
162{ 160{
163 av = perlav; 161 av = perlav;
164 text = newSVpv (data, 0); 162 text = newSVpv (data, 0);
165 sv_catpv (text, thawer_eof); 163 sv_catpv (text, thawer_eof);
166 line = SvPVbyte_nolen (text); 164 line = SvPVbyte_nolen (text);
165 next ();
167} 166}
168 167
169void 168void
170object_thawer::get (attachable *obj, int oid) 169object_thawer::get (attachable *obj, int oid)
171{ 170{
222object_thawer::~object_thawer () 221object_thawer::~object_thawer ()
223{ 222{
224 if (text) SvREFCNT_dec (text); 223 if (text) SvREFCNT_dec (text);
225 if (av) SvREFCNT_dec (av); 224 if (av) SvREFCNT_dec (av);
226 225
226 resolve_delayed_derefs (false);
227
227 free ((void *)name); 228 free ((void *)name);
228} 229}
229 230
230//TODO: remove 231//TODO: remove
231char * 232char *
253 254
254 *q = 0; 255 *q = 0;
255 thawer.line = p; 256 thawer.line = p;
256 257
257 return s == q ? 0 : s; 258 return s == q ? 0 : s;
259}
260
261void
262object_thawer::parse_warn (const char *msg)
263{
264 LOG (llevWarn, "%s:%d, \"%s %s\": %s\n",
265 this->name, linenum,
266 kw_str ? kw_str : "<null>",
267 value ? value : "<null>",
268 msg);
258} 269}
259 270
260bool 271bool
261object_thawer::parse_error (const char *type, const char *name, bool skip) 272object_thawer::parse_error (const char *type, const char *name, bool skip)
262{ 273{
279 290
280 default: 291 default:
281 LOG (llevError, "%s:%d unexpected line (%s %s) while reading %s '%s', %s.\n", 292 LOG (llevError, "%s:%d unexpected line (%s %s) while reading %s '%s', %s.\n",
282 this->name, linenum, 293 this->name, linenum,
283 kw_str ? kw_str : "<null>", 294 kw_str ? kw_str : "<null>",
284 value ? value : "<null>", 295 value ? value : "<null>",
285 type, name, 296 type, name,
286 skip ? "skipping line" : "aborting load"); 297 skip ? "skipping line" : "aborting load");
287 return skip; 298 return skip;
288 } 299 }
289} 300}
376 387
377 next (); 388 next ();
378} 389}
379 390
380void 391void
392object_thawer::skip_block ()
393{
394 while (kw != KW_ERROR && kw != KW_EOF)
395 {
396 keyword w = kw;
397 skip ();
398 if (w == KW_end)
399 break;
400 }
401}
402
403void
381object_thawer::get_ml (keyword kend, shstr &sh) 404object_thawer::get_ml (keyword kend, shstr &sh)
382{ 405{
383 char kw[128]; 406 char kw[128];
384 407
385 int klen = keyword_len [kend]; 408 int klen = keyword_len [kend];
452 while (*p); 475 while (*p);
453 476
454 return negate ? -val : val; 477 return negate ? -val : val;
455} 478}
456 479
480void
481object_thawer::delayed_deref (attachable *op, object_ptr &ptr, const char *ref)
482{
483 op->refcnt_inc ();
484 delayed_ref r = { op, &ptr, ref ? strdup (ref) : 0 };
485 delrefs.push_back (r);
486 ptr = 0;
487}
488
489void
490object_thawer::resolve_delayed_derefs (bool deref)
491{
492 while (!delrefs.empty ())
493 {
494 delayed_ref r = delrefs.back ();
495 delrefs.pop_back ();
496
497 if (deref)
498 *r.ptr = object::deref (r.ref);
499
500 free ((void *)r.ref);
501 r.op->refcnt_dec ();
502 }
503}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines