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.47 by root, Wed Nov 16 23:42:02 2016 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 (©) 2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * 5 *
6 * Deliantra is free software: you can redistribute it and/or modify it under 6 * 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 7 * 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 8 * Free Software Foundation, either version 3 of the License, or (at your
9 * 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 Affero GNU General Public License 16 * 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 17 * and the GNU General Public License along with this program. If not, see
18 * <http://www.gnu.org/licenses/>. 18 * <http://www.gnu.org/licenses/>.
19 * 19 *
20 * The authors can be reached via e-mail to <support@deliantra.net> 20 * The authors can be reached via e-mail to <support@deliantra.net>
21 */ 21 */
22 22
23#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
24#include "logger.h" 24#include "logger.h"
109bool object_thawer::errors_are_fatal = true; 109bool object_thawer::errors_are_fatal = true;
110 110
111object_thawer::object_thawer (const char *data, AV *perlav) 111object_thawer::object_thawer (const char *data, AV *perlav)
112: name (strdup ("(memory stream)")) 112: name (strdup ("(memory stream)"))
113{ 113{
114 init ("(memory stream)");
115
114 av = perlav; 116 av = perlav;
115 text = newSVpv (data, 0); 117 text = newSVpv (data, 0); sv_catpv (text, thawer_eof);
116 sv_catpv (text, thawer_eof);
117 line = SvPVbyte_nolen (text); 118 line = SvPVbyte_nolen (text);
118 next (); 119 next ();
119} 120}
120 121
121object_thawer::object_thawer (const_utf8_string path) 122object_thawer::object_thawer (const_utf8_string path)
122{ 123{
123 new_from_path (path); 124 init_from_file (path);
124} 125}
125 126
126// convenience constructor 127// convenience constructor
127object_thawer::object_thawer (const_utf8_string dir, const_utf8_string file) 128object_thawer::object_thawer (const_utf8_string dir, const_utf8_string file)
128{ 129{
129 new_from_path (format ("%s/%s", dir, file)); 130 init_from_file (format ("%s/%s", dir, file));
130} 131}
131 132
132void 133void
133object_thawer::new_from_path (const_utf8_string path) 134object_thawer::init (const_utf8_string path)
134{ 135{
135 name = strdup (path); 136 name = strdup (path);
136 av = 0; 137 av = 0;
137 text = 0; 138 text = 0;
138 line = 0; 139 line = 0;
139 linenum = 0; 140 linenum = 0;
140 141
141 kw = KW_ERROR; 142 kw = KW_ERROR;
142 kw_str = 0; 143 kw_str = 0;
143 value = 0; 144 value = 0;
145}
144 146
147void
148object_thawer::init_from_file (const_utf8_string path)
149{
145 if (path) 150 init (path);
146 { 151
147 CALL_BEGIN (1); 152 CALL_BEGIN (1);
148 CALL_ARG_SV (newSVpv (path, 0)); 153 CALL_ARG_SV (newSVpv (path, 0));
149 CALL_CALL ("cf::object_thawer_load", G_ARRAY); 154 CALL_CALL ("cf::object_thawer_load", G_ARRAY);
150 155
151 if (count == 2) 156 if (count == 2)
152 { 157 {
153 // second value - perl objects 158 // second value - perl objects
154 { 159 {
155 SV *sv = POPs; 160 SV *sv = POPs;
156 if (SvROK (sv)) 161 if (SvROK (sv))
157 av = (AV *)SvREFCNT_inc (SvRV (sv)); 162 av = (AV *)SvREFCNT_inc (SvRV (sv));
158 } 163 }
159 164
160 // first value - text part, pad with 3 zeroes 165 // first value - text part, pad with 3 zeroes
161 { 166 {
162 SV *sv = POPs; 167 SV *sv = POPs;
163 STRLEN len; 168 STRLEN len;
164 char *sv_ = SvPVbyte (sv, len); 169 char *sv_ = SvPVbyte (sv, len);
165 text = newSV (len + sizeof (thawer_eof)); 170 text = newSV (len + sizeof (thawer_eof));
166 SvCUR_set (text, len + sizeof (thawer_eof)); 171 SvCUR_set (text, len + sizeof (thawer_eof));
167 memcpy (SvPVX (text), sv_, len); 172 memcpy (SvPVX (text), sv_, len);
168 memcpy (SvPVX (text) + len, thawer_eof, sizeof (thawer_eof)); 173 memcpy (SvPVX (text) + len, thawer_eof, sizeof (thawer_eof));
169 174
170 line = SvPVX (text); 175 line = SvPVX (text);
171 next (); 176 next ();
172 }
173 } 177 }
178 }
174 179
175 CALL_END; 180 CALL_END;
176 }
177} 181}
178 182
179void 183void
180object_thawer::get (attachable *obj, int oid) 184object_thawer::get (attachable *obj, int oid)
181{ 185{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines