--- deliantra/server/common/player.C 2010/04/11 00:34:05 1.67 +++ deliantra/server/common/player.C 2016/11/16 23:41:59 1.75 @@ -1,24 +1,24 @@ /* * 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 (©) 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 - * + * * 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 */ @@ -238,11 +238,9 @@ for (int i = 1; i <= count; i++) { - char line [32]; - - fgets (line, 32, f); pl->levhp [i] = atoi (line); - fgets (line, 32, f); pl->levsp [i] = atoi (line); - fgets (line, 32, f); pl->levgrace[i] = atoi (line); + f.next_line (); f.get (pl->levhp [i]); + f.next_line (); f.get (pl->levsp [i]); + f.next_line (); f.get (pl->levgrace[i]); } } break; @@ -287,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); @@ -366,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; @@ -398,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 @@ -423,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 (); @@ -431,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); @@ -449,7 +462,7 @@ } buf << pfx; - cfpod = expand_cfpod (pl, buf, cfpod, end); + cfpod = expand_cfpod (hintmode, gender, buf, cfpod, end); buf << sfx; } @@ -466,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') @@ -479,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); +} +