--- deliantra/server/include/cfperl.h 2010/04/15 03:34:30 1.121
+++ deliantra/server/include/cfperl.h 2018/12/05 19:13:21 1.133
@@ -1,22 +1,23 @@
/*
* This file is part of Deliantra, the Roguelike Realtime MMORPG.
- *
- * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
- *
+ *
+ * Copyright (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team
+ * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
+ *
* Deliantra is free software: you can redistribute it and/or modify it under
* the terms of the Affero GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the Affero GNU General Public License
* and the GNU General Public License along with this program. If not, see
* .
- *
+ *
* The authors can be reached via e-mail to
*/
@@ -103,6 +104,7 @@
void cfperl_send_msg (client *ns, int color, const_utf8_string type, const_utf8_string msg);
int cfperl_can_merge (object *ob1, object *ob2);
void cfperl_mapscript_activate (object *ob, int state, object *activator, object *originator = 0);
+void cfperl_ix (client *ns, int set, faceidx idx, int pri);
bool is_match_expr (const_utf8_string expr);
// applies the match expression and returns true if it matches
@@ -131,6 +133,8 @@
extern tstamp runtime; // virtual server time, excluding time jumps and lag
extern tstamp NOW; // real time of current server tick
+ecb_noinline utf8_string cfSvPVutf8_nolen (SV *sv);
+
enum event_klass
{
KLASS_NONE,
@@ -170,7 +174,7 @@
#define ARG_REGION(o) DT_REGION, (void *)(static_cast (o))
// the ", ## __VA_ARGS" is, unfortunately, a gnu-cpp extension
-#define INVOKE(obj,event, ...) (expect_false ((obj)->should_invoke (event)) ? (obj)->invoke (event, ## __VA_ARGS__, DT_END) : 0)
+#define INVOKE(obj,event, ...) (ecb_expect_false ((obj)->should_invoke (event)) ? (obj)->invoke (event, ## __VA_ARGS__, DT_END) : 0)
#define INVOKE_GLOBAL(event, ...) INVOKE (&gbl_ev, EVENT_ ## GLOBAL ## _ ## event, ## __VA_ARGS__)
#define INVOKE_ATTACHABLE(event, obj, ...) INVOKE (obj , EVENT_ ## ATTACHABLE ## _ ## event, ## __VA_ARGS__)
#define INVOKE_OBJECT(event, obj, ...) INVOKE (obj , EVENT_ ## OBJECT ## _ ## event, ## __VA_ARGS__)
@@ -205,7 +209,7 @@
// object is delete'd after the refcount reaches 0
MTH int refcnt_cnt () const;
// check wether the object has died and destroy
- MTH void refcnt_chk () { if (expect_false (refcnt <= 0)) do_check (); }
+ MTH void refcnt_chk () { if (ecb_expect_false (refcnt <= 0)) do_check (); }
// destroy the object unless it was already destroyed
// this politely asks everybody interested the reduce
@@ -264,7 +268,7 @@
return ev_want_event [event] || cb;
}
- bool invoke (event_type event, ...);
+ bool invoke (/*event_type*/int event, ...);
MTH void instantiate ();
void reattach ();
@@ -290,215 +294,7 @@
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// a little dirty hack, maybe unify with something else at a later time
-// it is used to communicate as much info about the keyword string
-// to the consuemr as possible, for maximum performance.
-struct keyword_string
-{
- const char *s;
- const int l;
-
- keyword_string (const char *s, int l)
- : s(s), l(l)
- { }
-
- keyword_string (keyword kw)
- : s(keyword_str [kw]), l(keyword_len [kw])
- {
- }
-
- keyword_string (shstr_tmp sh)
- : s(&sh), l(sh.length ())
- {
- }
-};
-
-#define CS(keyword) keyword_string (# keyword, sizeof (# keyword) - 1)
-#define KW(keyword) CS(keyword)
-
-INTERFACE_CLASS(object_freezer)
-struct object_freezer : dynbuf_text
-{
- AV *av;
-
- object_freezer ();
- ~object_freezer ();
-
- // serialise perl part
- void put_ (attachable *ext);
- void put (attachable *ext)
- {
- if (expect_false (ext->self))
- put_ (ext);
- }
-
- // null value (== no space after keyword)
- void put (const keyword_string k)
- {
- char *p = force (k.l + 1);
- memcpy (p, k.s, k.l); p += k.l; *p++ = '\n';
- alloc (p);
- }
-
- void put (const keyword_string k, const keyword_string v)
- {
- char *p = force (k.l + 1 + v.l + 1);
- memcpy (p, k.s, k.l); p += k.l; *p++ = ' ';
- memcpy (p, v.s, v.l); p += v.l; *p++ = '\n';
- alloc (p);
- }
-
- void put (const keyword_string k, const_utf8_string v)
- {
- if (expect_true (v))
- put (k, keyword_string (v, strlen (v)));
- else
- put (k);
- }
-
- void put (const keyword_string k, shstr_tmp v)
- {
- put (k, keyword_string (v));
- }
-
- void put (const keyword_string k, double v)
- {
- char *p = force (MAX_KEYWORD_LEN + 2 + 32);
- memcpy (p, k.s, k.l); p += k.l; *p++ = ' ';
- p += sprintf (p, "%.7g", v); *p++ = '\n';
- alloc (p);
- }
-
- void put_(const keyword_string k, sint64 v)
- {
- force (MAX_KEYWORD_LEN + 2 + sint64_digits);
- fadd (k.s, k.l);
- fadd (' ');
- add (v);
- fadd ('\n');
- }
-
- void put_(const keyword_string k, sint32 v)
- {
- force (MAX_KEYWORD_LEN + 2 + sint32_digits);
- fadd (k.s, k.l);
- fadd (' ');
- add (v);
- fadd ('\n');
- }
-
- void put (const keyword_string k, float v) { put (k, (double)v); }
- void put (const keyword_string k, signed char v) { put_(k, (sint32)v); }
- void put (const keyword_string k, unsigned char v) { put_(k, (sint32)v); }
- void put (const keyword_string k, signed short v) { put_(k, (sint32)v); }
- void put (const keyword_string k, unsigned short v) { put_(k, (sint32)v); }
- void put (const keyword_string k, signed int v) { put_(k, (sint32)v); }
- void put (const keyword_string k, unsigned int v) { put_(k, (sint64)v); }
- void put (const keyword_string k, signed long v) { put_(k, (sint64)v); }
- void put (const keyword_string k, unsigned long v) { put_(k, (sint64)v); }
- void put (const keyword_string k, signed long long v) { put_(k, (sint64)v); }
- void put (const keyword_string k, unsigned long long v) { put_(k, (sint64)v); }
-
- void put (const keyword_string kbeg, const keyword_string kend, shstr_tmp v)
- {
- force (MAX_KEYWORD_LEN + 1);
- fadd (kbeg.s, kbeg.l); fadd ('\n');
-
- if (expect_true (v))
- {
- add (v);
- add ('\n');
- }
-
- force (MAX_KEYWORD_LEN + 1);
- fadd (kend.s, kend.l); fadd ('\n');
- }
-
- void put (const keyword_string k, archetype *v);
- void put (const keyword_string k, treasurelist *v);
- void put (const keyword_string k, faceinfo *v);
-
- template
- void put (const keyword_string k, const refptr &v)
- {
- put (k, (T *)v);
- }
-
- MTH bool save (const_octet_string path);
- utf8_string as_string (); // like strdup
-
- operator bool () { return !!av; }
-};
-
-INTERFACE_CLASS(object_thawer)
-struct object_thawer
-{
- char *line; // current beginning of line
- SV *text; // text part
- AV *av; // perl part
- int linenum;
- keyword kw;
- char *kw_str; // the keyword parsed, as string
- char *value; // the value, or 0 if no value
- const char *value_nn; // the value, or the empty string if no value
- const char *name;
-
- operator bool () const { return !!text; }
-
- object_thawer (const_utf8_string path = 0);
- object_thawer (const_utf8_string data, AV *perlav);
- ~object_thawer ();
-
- void get (attachable *obj, int oid);
-
- // parse next line
- MTH void next ();
- // skip the current key-value (usually fetch next line, for
- // multiline-fields, skips till the corresponding end-kw
- MTH void skip ();
- MTH void skip_block (); // skips till and over KW_end
-
- bool has_value () { return value; }
- const_utf8_string get_str () { return value_nn; } // empty string when missing
- void get_ml (keyword kend, shstr &sh);
-
- void get_ornull (shstr &sh) const { sh = value; }
- void get (shstr &sh) const { sh = value; } // might want to check for non-null here
-
- bool get_bool () const { return *value_nn == '1'; }
- sint32 get_sint32 () const;
- sint64 get_sint64 () const { return strtoll (value_nn, 0, 10); }
- double get_double () const { return strtod (value_nn, 0); }
-
- void get (float &v) { v = get_double (); }
- void get (double &v) { v = get_double (); }
-
- void get (bool &i) { i = get_bool (); }
- void get (sint8 &i) { i = get_sint32 (); }
- void get (uint8 &i) { i = get_sint32 (); }
- void get (sint16 &i) { i = get_sint32 (); }
- void get (uint16 &i) { i = get_sint32 (); }
- void get (sint32 &i) { i = get_sint32 (); }
-
- void get (uint32 &i) { i = get_sint64 (); }
- void get (sint64 &i) { i = get_sint64 (); }
-
- MTH void parse_warn (const_utf8_string msg);
- MTH bool parse_error (const_utf8_string type = 0, const_utf8_string name = 0, bool skip = true);
-
- struct delayed_ref {
- attachable *op;
- object_ptr *ptr;
- const_utf8_string ref;
- };
- std::vector delrefs;
-
- void delayed_deref (attachable *op, object_ptr &ptr, const_utf8_string ref);
- MTH void resolve_delayed_derefs (bool deref = true);
-};
-
-//TODO: remove
-char *fgets (char *s, int n, object_thawer &thawer);
+#include "freezethaw.h"
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -515,7 +311,7 @@
// actually cede's far more often
static bool cede_to_tick ()
{
- if (expect_true (!cede_pending))
+ if (ecb_expect_true (!cede_pending))
return false;
do_cede_to_tick ();