ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/cf.schmorp.de/dclient/src/backend/communicator/command_parser/fx.h
Revision: 1.3
Committed: Wed Oct 20 08:33:41 2010 UTC (16 years ago) by sf-pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.2: +20 -11 lines
Log Message:
2 glyphs / map space

File Contents

# User Rev Content
1 sf-pippijn 1.1 #include "deliantra/data/fx.h"
2     #include "deliantra/data/glyph.h"
3    
4 sf-pippijn 1.3 static bool
5     read_glyph_part (char const *&data, size_t &length, data::glyph::part &part)
6 sf-pippijn 1.2 {
7 sf-pippijn 1.3 return_val_unless (length > 2, false);
8    
9     part.fg = data[0];
10     part.bg = data[1];
11    
12     int len;
13     return_val_unless ((len = mbtowc (&part.text, data + 2, length - 2)) != -1, false);
14    
15     length -= len + 2;
16     data += len + 2;
17    
18     return true;
19 sf-pippijn 1.2 }
20    
21 sf-pippijn 1.1 void
22     command_parser::on_fx (std::istream &args)
23     {
24     std::vector<data::fx> faces;
25    
26     u32 type = 0;
27     while (args.peek () != EOF)
28     {
29     u32 facenum = read_ber32 (args);
30     std::string name = read_string08 (args);
31    
32     if (facenum)
33     {
34     data::glyph glyph;
35     if (!name.empty ())
36     {
37 sf-pippijn 1.3 char const *data = name.data ();
38     size_t length = name.length ();
39     return_unless (read_glyph_part (data, length, glyph[0]));
40     return_unless (read_glyph_part (data, length, glyph[1]));
41     return_unless (length == 0);
42 sf-pippijn 1.1 }
43     data::register_glyph (facenum, glyph);
44 sf-pippijn 1.3 faces.emplace_back (data::fx { type, facenum, std::move (name) });
45 sf-pippijn 1.1 }
46     else if (name.length () == 1)
47     type = name[0];
48     }
49    
50     emit fx (faces);
51     }