game2006/server/gameserver/typeconvert.cc
2022-12-12 15:45:35 +08:00

80 lines
2.0 KiB
C++

#include "precompile.h"
#include "typeconvert.h"
#include "cs_proto.pb.h"
#include "human.h"
namespace TypeConvert
{
void ToPb(const a8::Vec2& v, cs::MFVec2* pb_obj)
{
pb_obj->set_x(v.x);
pb_obj->set_y(v.y);
}
void ToPb(const Position& v, cs::MFVec2* pb_obj)
{
pb_obj->set_x(v.x);
pb_obj->set_y(v.y);
}
void ToPb(const Position v, cs::MFVec3* pb_obj)
{
pb_obj->set_x(v.x);
pb_obj->set_y(v.y);
pb_obj->set_z(v.z);
}
void ToPb(const a8::Vec2& v, cs::MFVec3* pb_obj)
{
pb_obj->set_x(v.x);
pb_obj->set_y(v.y);
pb_obj->set_z(0.0f);
}
void FromPb(a8::Vec2& v, const cs::MFVec2* pb_obj)
{
v.x = pb_obj->x();
v.y = pb_obj->y();
}
void FromPb(a8::Vec2& v, const cs::MFVec3* pb_obj)
{
v.x = pb_obj->x();
v.y = pb_obj->y();
}
void ToPb(const a8::Vec3& v, cs::MFVec3* pb_obj)
{
pb_obj->set_x(v.x);
pb_obj->set_y(v.y);
pb_obj->set_z(v.z);
}
void FromPb(a8::Vec3& v, const cs::MFVec3* pb_obj)
{
v.x = pb_obj->x();
v.y = pb_obj->y();
v.z = pb_obj->z();
}
void ToPb(const OverReward& v, cs::MFOverReward* pb_obj)
{
pb_obj->mutable_hero()->set_id(v.hero.id);
pb_obj->mutable_hero()->set_curr_gold(v.hero.curr_gold);
pb_obj->mutable_hero()->set_obtain_gold(v.hero.obtain_gold);
pb_obj->mutable_hero()->set_gold_limit(v.hero.gold_limit);
pb_obj->mutable_weapon1()->set_id(v.weapon1.id);
pb_obj->mutable_weapon1()->set_curr_gold(v.weapon1.curr_gold);
pb_obj->mutable_weapon1()->set_obtain_gold(v.weapon1.obtain_gold);
pb_obj->mutable_weapon1()->set_gold_limit(v.weapon1.gold_limit);
pb_obj->mutable_weapon2()->set_id(v.weapon2.id);
pb_obj->mutable_weapon2()->set_curr_gold(v.weapon2.curr_gold);
pb_obj->mutable_weapon2()->set_obtain_gold(v.weapon2.obtain_gold);
pb_obj->mutable_weapon2()->set_gold_limit(v.weapon2.gold_limit);
}
}