ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/cf.schmorp.de/dclient/src/backend/communicator/command_parser/upditem.h
Revision: 1.2
Committed: Mon Oct 25 12:06:58 2010 UTC (15 years, 11 months ago) by sf-pippijn
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +2 -0 lines
Log Message:
be more strict about the protocol

File Contents

# User Rev Content
1 sf-pippijn 1.1 void
2     command_parser::on_upditem (std::istream &args)
3     {
4     u08 const flags = read_u08 (args);
5     u32 location = 0;
6    
7     data::item item { };
8    
9     item.tag = read_u32 (args);
10    
11     if (flags & UPD_LOCATION) location = read_u32 (args);
12    
13     if (flags & UPD_FLAGS) item.flags = read_u32 (args);
14     if (flags & UPD_WEIGHT) item.weight = read_u32 (args);
15     if (flags & UPD_FACE) item.face = read_u32 (args);
16    
17     if (flags & UPD_NAME)
18     {
19     std::string names = read_string08 (args);
20    
21     auto pair = split2 (names, '\0');
22     item.singular = pair.first;
23     item.plural = pair.second;
24     }
25    
26     if (flags & UPD_ANIM) item.anim = read_u16 (args);
27     if (flags & UPD_ANIMSPEED) item.animspeed = read_u08 (args);
28     if (flags & UPD_NROF) item.nrof = read_u32 (args);
29    
30 sf-pippijn 1.2 PARSE_END;
31    
32 sf-pippijn 1.1 emit upditem (flags, location, item);
33     }