ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/cfperl.h
(Generate patch)

Comparing deliantra/server/include/cfperl.h (file contents):
Revision 1.113 by root, Mon Nov 16 22:31:14 2009 UTC vs.
Revision 1.117 by root, Fri Apr 2 03:41:24 2010 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 (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010 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.
99void cfperl_main (); 99void cfperl_main ();
100void cfperl_tick (); 100void cfperl_tick ();
101void cfperl_emergency_save (); 101void cfperl_emergency_save ();
102void cfperl_cleanup (int make_core); 102void cfperl_cleanup (int make_core);
103void cfperl_make_book (object *book, int level); 103void cfperl_make_book (object *book, int level);
104void cfperl_send_msg (client *ns, int color, const char *type, const char *msg); 104void cfperl_send_msg (client *ns, int color, const_utf8_string type, const_utf8_string msg);
105int cfperl_can_merge (object *ob1, object *ob2); 105int cfperl_can_merge (object *ob1, object *ob2);
106void cfperl_mapscript_activate (object *ob, int state, object *activator, object *originator = 0); 106void cfperl_mapscript_activate (object *ob, int state, object *activator, object *originator = 0);
107 107
108bool is_match_expr (const char *expr); 108bool is_match_expr (const_utf8_string expr);
109// applies the match expression and returns true if it matches 109// applies the match expression and returns true if it matches
110bool match (const char *expr, object *ob, object *self = 0, object *source = 0, object *originator = 0); 110bool match (const_utf8_string expr, object *ob, object *self = 0, object *source = 0, object *originator = 0);
111// same as above, but returns the first object found, or 0 111// same as above, but returns the first object found, or 0
112object *match_one (const char *expr, object *ob, object *self = 0, object *source = 0, object *originator = 0); 112object *match_one (const_utf8_string expr, object *ob, object *self = 0, object *source = 0, object *originator = 0);
113 113
114////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 114//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
115 115
116#if IVSIZE >= 8 116#if IVSIZE >= 8
117 typedef IV val64; 117 typedef IV val64;
240 : attachable_flags (0), self (0), cb (0), attach (src.attach) 240 : attachable_flags (0), self (0), cb (0), attach (src.attach)
241 { 241 {
242 } 242 }
243 243
244 // set a custom key to the given value, or delete it if value = 0 244 // set a custom key to the given value, or delete it if value = 0
245 void set_key (const char *key, const char *value = 0, bool is_utf8 = 0); 245 void set_key (const_utf8_string key, const_utf8_string value = 0, bool is_utf8 = 0);
246 246
247 void set_key_text (const char *key, const char *value = 0) 247 void set_key_text (const_utf8_string key, const_utf8_string value = 0)
248 { 248 {
249 set_key (key, value, 1); 249 set_key (key, value, 1);
250 } 250 }
251 251
252 void set_key_data (const char *key, const char *value = 0) 252 void set_key_data (const_utf8_string key, const_utf8_string value = 0)
253 { 253 {
254 set_key (key, value, 0); 254 set_key (key, value, 0);
255 } 255 }
256 256
257 attachable &operator =(const attachable &src); 257 attachable &operator =(const attachable &src);
258 258
259 // used to _quickly_ device wether to shortcut the evaluation 259 // used to _quickly_ decide wether to shortcut the evaluation
260 bool should_invoke (event_type event) 260 bool should_invoke (event_type event)
261 { 261 {
262 return ev_want_event [event] || cb; 262 return ev_want_event [event] || cb;
263 } 263 }
264 264
342 memcpy (p, k.s, k.l); p += k.l; *p++ = ' '; 342 memcpy (p, k.s, k.l); p += k.l; *p++ = ' ';
343 memcpy (p, v.s, v.l); p += v.l; *p++ = '\n'; 343 memcpy (p, v.s, v.l); p += v.l; *p++ = '\n';
344 alloc (p); 344 alloc (p);
345 } 345 }
346 346
347 void put (const keyword_string k, const char *v) 347 void put (const keyword_string k, const_utf8_string v)
348 { 348 {
349 if (expect_true (v)) 349 if (expect_true (v))
350 put (k, keyword_string (v, strlen (v))); 350 put (k, keyword_string (v, strlen (v)));
351 else 351 else
352 put (k); 352 put (k);
419 { 419 {
420 put (k, (T *)v); 420 put (k, (T *)v);
421 } 421 }
422 422
423 MTH bool save (const_octet_string path); 423 MTH bool save (const_octet_string path);
424 char *as_string (); // like strdup 424 utf8_string as_string (); // like strdup
425 425
426 operator bool () { return !!av; } 426 operator bool () { return !!av; }
427}; 427};
428 428
429INTERFACE_CLASS(object_thawer) 429INTERFACE_CLASS(object_thawer)
439 const char *value_nn; // the value, or the empty string if no value 439 const char *value_nn; // the value, or the empty string if no value
440 const char *name; 440 const char *name;
441 441
442 operator bool () const { return !!text; } 442 operator bool () const { return !!text; }
443 443
444 object_thawer (const char *path = 0); 444 object_thawer (const_utf8_string path = 0);
445 object_thawer (const char *data, AV *perlav); 445 object_thawer (const_utf8_string data, AV *perlav);
446 ~object_thawer (); 446 ~object_thawer ();
447 447
448 void get (attachable *obj, int oid); 448 void get (attachable *obj, int oid);
449 449
450 // parse next line 450 // parse next line
453 // multiline-fields, skips till the corresponding end-kw 453 // multiline-fields, skips till the corresponding end-kw
454 MTH void skip (); 454 MTH void skip ();
455 MTH void skip_block (); // skips till and over KW_end 455 MTH void skip_block (); // skips till and over KW_end
456 456
457 bool has_value () { return value; } 457 bool has_value () { return value; }
458 const char *get_str () { return value_nn; } // empty string when missing 458 const_utf8_string get_str () { return value_nn; } // empty string when missing
459 void get_ml (keyword kend, shstr &sh); 459 void get_ml (keyword kend, shstr &sh);
460 460
461 void get_ornull (shstr &sh) const { sh = value; } 461 void get_ornull (shstr &sh) const { sh = value; }
462 void get (shstr &sh) const { sh = value; } // might want to check for non-null here 462 void get (shstr &sh) const { sh = value; } // might want to check for non-null here
463 463
477 void get (sint32 &i) { i = get_sint32 (); } 477 void get (sint32 &i) { i = get_sint32 (); }
478 478
479 void get (uint32 &i) { i = get_sint64 (); } 479 void get (uint32 &i) { i = get_sint64 (); }
480 void get (sint64 &i) { i = get_sint64 (); } 480 void get (sint64 &i) { i = get_sint64 (); }
481 481
482 MTH void parse_warn (const char *msg); 482 MTH void parse_warn (const_utf8_string msg);
483 MTH bool parse_error (const char *type = 0, const char *name = 0, bool skip = true); 483 MTH bool parse_error (const_utf8_string type = 0, const_utf8_string name = 0, bool skip = true);
484 484
485 struct delayed_ref { 485 struct delayed_ref {
486 attachable *op; 486 attachable *op;
487 object_ptr *ptr; 487 object_ptr *ptr;
488 const char *ref; 488 const_utf8_string ref;
489 }; 489 };
490 std::vector<delayed_ref> delrefs; 490 std::vector<delayed_ref> delrefs;
491 491
492 void delayed_deref (attachable *op, object_ptr &ptr, const char *ref); 492 void delayed_deref (attachable *op, object_ptr &ptr, const_utf8_string ref);
493 MTH void resolve_delayed_derefs (bool deref = true); 493 MTH void resolve_delayed_derefs (bool deref = true);
494}; 494};
495 495
496//TODO: remove 496//TODO: remove
497char *fgets (char *s, int n, object_thawer &thawer); 497char *fgets (char *s, int n, object_thawer &thawer);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines