Linux multi-monitor fullscreen support
[ryzomcore.git] / ryzom / common / src / game_share / action_block.cpp
blobbe9c3a8cae19c5ed80f236892ce32ee40faffca3
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "stdpch.h"
21 #include "action_block.h"
22 #include "action_factory.h"
24 using namespace NLMISC;
26 namespace CLFECOMMON {
29 CActionBlock::~CActionBlock()
31 uint i;
32 for (i=0; i<Actions.size(); ++i)
33 CActionFactory::getInstance()->remove(Actions[i]);
36 void CActionBlock::serial(CBitMemStream &msg)
38 if (!msg.isReading() && Cycle == 0)
39 nlwarning("Packing action block (%d actions) with unset date", Actions.size());
41 msg.serial(Cycle);
43 uint i;
45 uint8 num = (uint8)Actions.size();
46 msg.serial(num);
48 //static char buff[1024], cat[128];
50 if (msg.isReading())
52 //sprintf(buff, "Unpack[%d]:", Cycle);
53 for (i=0; i<num; ++i)
55 CAction *action = CActionFactory::getInstance()->unpack(msg, false);
56 if ( ! action )
58 Success = false; // reject an incorrect block
60 else
62 //sprintf(cat, " %d(%d bits)", action->Code, action->size());
63 //strcat(buff, cat);
64 Actions.push_back(action);
68 else
70 //sprintf(buff, "Pack[%d]:", Cycle);
71 for (i=0; i<num; ++i)
73 uint msgPosBefore = msg.getPosInBit();
74 CActionFactory::getInstance()->pack(Actions[i], msg, false);
75 uint msgPosAfter = msg.getPosInBit();
77 uint actionSize = CActionFactory::getInstance()->size(Actions[i]);
79 if (actionSize < msgPosAfter-msgPosBefore)
80 nlwarning("Action %d declares a lower size (%d bits) from what it actually serialises (%d bits)", Actions[i]->Code, actionSize, msgPosAfter-msgPosBefore);
81 //sprintf(cat, " %d(%d bits)", Actions[i]->Code, Actions[i]->size());
82 //strcat(buff, cat);
85 //nlinfo("Block: %s", buff);
88 } // CLFECOMMON