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.42 by root, Thu Apr 29 12:24:04 2010 UTC vs.
Revision 1.49 by root, Wed Dec 5 19:03:27 2018 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 (©) 2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 5 * Copyright (©) 2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * 6 *
6 * Deliantra is free software: you can redistribute it and/or modify it under 7 * Deliantra is free software: you can redistribute it and/or modify it under
7 * the terms of the Affero GNU General Public License as published by the 8 * the terms of the Affero GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your 9 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version. 10 * option) any later version.
10 * 11 *
11 * This program is distributed in the hope that it will be useful, 12 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 15 * GNU General Public License for more details.
15 * 16 *
16 * You should have received a copy of the Affero GNU General Public License 17 * You should have received a copy of the Affero GNU General Public License
17 * and the GNU General Public License along with this program. If not, see 18 * and the GNU General Public License along with this program. If not, see
18 * <http://www.gnu.org/licenses/>. 19 * <http://www.gnu.org/licenses/>.
19 * 20 *
20 * The authors can be reached via e-mail to <support@deliantra.net> 21 * The authors can be reached via e-mail to <support@deliantra.net>
21 */ 22 */
22 23
23#include "global.h" // bug in cfperl.h, doesn't include interface_class stuff 24#include "global.h" // bug in cfperl.h, doesn't include interface_class stuff
24#include "logger.h" 25#include "logger.h"
109bool object_thawer::errors_are_fatal = true; 110bool object_thawer::errors_are_fatal = true;
110 111
111object_thawer::object_thawer (const char *data, AV *perlav) 112object_thawer::object_thawer (const char *data, AV *perlav)
112: name (strdup ("(memory stream)")) 113: name (strdup ("(memory stream)"))
113{ 114{
115 init ("(memory stream)");
116
114 av = perlav; 117 av = perlav;
115 text = newSVpv (data, 0); 118 text = newSVpv (data, 0); sv_catpv (text, thawer_eof);
116 sv_catpv (text, thawer_eof);
117 line = SvPVbyte_nolen (text); 119 line = SvPVbyte_nolen (text);
118 next (); 120 next ();
119} 121}
120 122
121object_thawer::object_thawer (const_utf8_string path) 123object_thawer::object_thawer (const_utf8_string path)
122{ 124{
123 new_from_path (path); 125 init_from_file (path);
124} 126}
125 127
126// convenience constructor 128// convenience constructor
127object_thawer::object_thawer (const_utf8_string dir, const_utf8_string file) 129object_thawer::object_thawer (const_utf8_string dir, const_utf8_string file)
128{ 130{
129 new_from_path (format ("%s/%s", dir, file)); 131 init_from_file (format ("%s/%s", dir, file));
130} 132}
131 133
132void 134void
133object_thawer::new_from_path (const_utf8_string path) 135object_thawer::init (const_utf8_string path)
134{ 136{
135 name = strdup (path); 137 name = strdup (path);
136 av = 0; 138 av = 0;
137 text = 0; 139 text = 0;
138 line = 0; 140 line = 0;
139 linenum = 0; 141 linenum = 0;
140 142
141 kw = KW_ERROR; 143 kw = KW_ERROR;
142 kw_str = 0; 144 kw_str = 0;
143 value = 0; 145 value = 0;
146}
144 147
148void
149object_thawer::init_from_file (const_utf8_string path)
150{
145 if (path) 151 init (path);
146 { 152
147 CALL_BEGIN (1); 153 CALL_BEGIN (1);
148 CALL_ARG_SV (newSVpv (path, 0)); 154 CALL_ARG_SV (newSVpv (path, 0));
149 CALL_CALL ("cf::object_thawer_load", G_ARRAY); 155 CALL_CALL ("cf::object_thawer_load", G_ARRAY);
150 156
151 if (count == 2) 157 if (count == 2)
152 { 158 {
153 // second value - perl objects 159 // second value - perl objects
154 { 160 {
155 SV *sv = POPs; 161 SV *sv = POPs;
156 if (SvROK (sv)) 162 if (SvROK (sv))
157 av = (AV *)SvREFCNT_inc (SvRV (sv)); 163 av = (AV *)SvREFCNT_inc (SvRV (sv));
158 } 164 }
159 165
160 // first value - text part, pad with 3 zeroes 166 // first value - text part, pad with 3 zeroes
161 { 167 {
162 SV *sv = POPs; 168 SV *sv = POPs;
163 STRLEN len; 169 STRLEN len;
164 char *sv_ = SvPVbyte (sv, len); 170 char *sv_ = SvPVbyte (sv, len);
165 text = newSV (len + sizeof (thawer_eof)); 171 text = newSV (len + sizeof (thawer_eof));
166 SvCUR_set (text, len + sizeof (thawer_eof)); 172 SvCUR_set (text, len + sizeof (thawer_eof));
167 memcpy (SvPVX (text), sv_, len); 173 memcpy (SvPVX (text), sv_, len);
168 memcpy (SvPVX (text) + len, thawer_eof, sizeof (thawer_eof)); 174 memcpy (SvPVX (text) + len, thawer_eof, sizeof (thawer_eof));
169 175
170 line = SvPVX (text); 176 line = SvPVX (text);
171 next (); 177 next ();
172 }
173 } 178 }
179 }
174 180
175 CALL_END; 181 CALL_END;
176 }
177} 182}
178 183
179void 184void
180object_thawer::get (attachable *obj, int oid) 185object_thawer::get (attachable *obj, int oid)
181{ 186{
304 309
305 for (;;) 310 for (;;)
306 { 311 {
307 char *p = line; 312 char *p = line;
308 313
309 if (expect_false (*p <= ' ')) 314 if (ecb_expect_false (*p <= ' '))
310 { 315 {
311 // skip whitespace (only some files need this) 316 // skip whitespace (only some files need this)
312 while (*p == ' ' || *p == '\t') 317 while (*p == ' ' || *p == '\t')
313 p++; 318 p++;
314 319
377 382
378 for (;;) 383 for (;;)
379 { 384 {
380 char *p = line; 385 char *p = line;
381 386
382 if (expect_false (*p <= ' ')) 387 if (ecb_expect_false (*p <= ' '))
383 { 388 {
384 // skip whitespace (only some files need this) 389 // skip whitespace (only some files need this)
385 while (*p == ' ' || *p == '\t') 390 while (*p == ' ' || *p == '\t')
386 p++; 391 p++;
387 392

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines