--- deliantra/server/common/player.C 2012/10/29 23:55:52 1.71
+++ deliantra/server/common/player.C 2016/11/16 23:41:59 1.75
@@ -1,7 +1,7 @@
/*
* This file is part of Deliantra, the Roguelike Realtime MMORPG.
*
- * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
+ * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
* Copyright (©) 2002 Mark Wedel & Crossfire Development Team
* Copyright (©) 1992 Frank Tore Johansen
*
@@ -285,8 +285,9 @@
// end == -1, till '>'
// end == 0, till eos
// end >= 1, levels of " >>>"
+// pod sequences not handled: F, S, X
static const char *
-expand_cfpod (const player *pl, dynbuf_text &buf, const char *cfpod, int end = 0)
+expand_cfpod (int hintmode, int gender, dynbuf_text &buf, const char *cfpod, int end = 0)
{
static dynbuf_text nest(128, 128);
@@ -364,9 +365,8 @@
break;
- case 'B': case 'C': case 'E': case 'G':
- case 'H': case 'I': case 'T': case 'U':
- case 'Z':
+ case 'B': case 'C': case 'E': case 'G': case 'H':
+ case 'I': case 'L': case 'T': case 'U': case 'Z':
{
int end = 0;
@@ -396,14 +396,29 @@
case 'T': pfx = ""; sfx = ""; break;
case 'Z': pfx = "" ; sfx = "" ; break;
+ case 'L': // link, not really supported - always use first (or only) component
+ {
+ cfpod = expand_cfpod (hintmode, gender, nest, cfpod, end);
+ nest << '\0'; // zero-terminate
+
+ const char *str = nest.linearise ();
+ const char *sep = strchr (str, '|');
+
+ buf.add (str, sep ? sep - str : nest.size ());
+
+ nest.clear ();
+
+ goto skip;
+ }
+
case 'H': // hint
{
- if (pl->hintmode)
+ if (hintmode)
{
- cfpod = expand_cfpod (pl, nest, cfpod, end);
+ cfpod = expand_cfpod (hintmode, gender, nest, cfpod, end);
nest.clear ();
- if (pl->hintmode == 1)
+ if (hintmode == 1)
buf << "[Hint available]";
else
while (*cfpod <= ' '&& *cfpod) // eat trailing whitespace
@@ -421,7 +436,7 @@
case 'G': // gender
{
- cfpod = expand_cfpod (pl, nest, cfpod, end);
+ cfpod = expand_cfpod (hintmode, gender, nest, cfpod, end);
nest << '\0'; // zero-terminate
const char *str = nest.linearise ();
@@ -429,7 +444,7 @@
if (sep)
{
- if (pl->gender)
+ if (gender)
buf.add (sep + 1, nest.size () - (sep - str) - 2);
else
buf.add (str, sep - str);
@@ -447,7 +462,7 @@
}
buf << pfx;
- cfpod = expand_cfpod (pl, buf, cfpod, end);
+ cfpod = expand_cfpod (hintmode, gender, buf, cfpod, end);
buf << sfx;
}
@@ -464,7 +479,7 @@
do
{
buf << "";
- cfpod = expand_cfpod (pl, buf, cfpod, -2);
+ cfpod = expand_cfpod (hintmode, gender, buf, cfpod, -2);
buf << "\n";
while (*cfpod == '\n')
@@ -477,13 +492,19 @@
}
dynbuf_text *
-player::expand_cfpod (const char *cfpod) const
+player::expand_cfpod (int hintmode, int gender, const_utf8_string cfpod)
{
- static dynbuf_text buf(1024, 1024);
+ static dynbuf_text buf(65536, 1024);
buf.clear ();
- ::expand_cfpod (this, buf, cfpod);
+ ::expand_cfpod (hintmode, gender, buf, cfpod);
return &buf;
}
+dynbuf_text *
+player::expand_cfpod (const_utf8_string cfpod) const
+{
+ return expand_cfpod (hintmode, gender, cfpod);
+}
+