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

Comparing deliantra/server/common/region.C (file contents):
Revision 1.34 by root, Wed Jul 11 16:55:18 2007 UTC vs.
Revision 1.37 by root, Thu Nov 8 19:43:23 2007 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 (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team 4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2001-2003,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2001-2003,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * Crossfire TRT is free software: you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or 10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version. 11 * (at your option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * 20 *
21 * The authors can be reached via e-mail to <crossfire@schmorp.de> 21 * The authors can be reached via e-mail to <support@deliantra.net>
22 */ 22 */
23 23
24#include <global.h> 24#include <global.h>
25#include <unistd.h> 25#include <unistd.h>
26 26
114 } 114 }
115 115
116 return default_region (); 116 return default_region ();
117} 117}
118 118
119void
120region::do_destroy ()
121{
122 regions.erase (this);
123
124 attachable::do_destroy ();
125
126 refcnt_dec ();
127}
128
119/* 129/*
120 * returns 1 if the player is in the region reg, or a child region thereof 130 * returns 1 if the player is in the region reg, or a child region thereof
121 * otherwise returns 0 131 * otherwise returns 0
122 * if passed a NULL region returns -1 132 * if passed a NULL region returns -1
123 */ 133 */
124
125static int 134static int
126region_is_child_of_region (const region * child, const region * r) 135region_is_child_of_region (const region * child, const region * r)
127{ 136{
128 137
129 if (r == NULL) 138 if (r == NULL)
184region::read (object_thawer &f) 193region::read (object_thawer &f)
185{ 194{
186 assert (f.kw == KW_region); 195 assert (f.kw == KW_region);
187 196
188 region *rgn = new region; 197 region *rgn = new region;
198 rgn->refcnt_inc ();
199
189 f.get (rgn->name); 200 f.get (rgn->name);
190 f.next (); 201 f.next ();
191 202
192 for (;;) 203 for (;;)
193 { 204 {
213 break; 224 break;
214 225
215 case KW_end: 226 case KW_end:
216 f.next (); 227 f.next ();
217 228
229 // cannot use find as that will request the default region
218 for_all_regions (old) 230 for_all_regions (old)
219 if (old->name == rgn->name) 231 if (old->name == rgn->name)
220 { 232 {
221 // replace, copy new values (ugly) 233 old->destroy ();
222 rgn->index = old->index;
223 *old = *rgn;
224 delete rgn;
225
226 return old; 234 break;
227 } 235 }
228 236
229 // just append 237 // just append
230 regions.push_back (rgn); 238 regions.push_back (rgn);
231 return rgn; 239 return rgn;
232 240
233 case KW_ERROR: 241 case KW_ERROR:
234 rgn->set_key (f.kw_str, f.value); 242 rgn->set_key_text (f.kw_str, f.value);
235 //fprintf (stderr, "region addkv(%s,%s)\n", f.kw_str, f.value);//D 243 //fprintf (stderr, "region addkv(%s,%s)\n", f.kw_str, f.value);//D
236 break; 244 break;
237 245
238 default: 246 default:
239 if (!f.parse_error ("region", rgn->name)) 247 if (!f.parse_error ("region", rgn->name))
240 { 248 {
241 delete rgn; 249 rgn->destroy ();
242 return 0; 250 return 0;
243 } 251 }
244 break; 252 break;
245 } 253 }
246 254

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines