示例#1
0
void MetaTexture::create(std::vector<sf::Texture>& textures)
{
	frames.resize(textures.size());
	for (unsigned int i = 0; i < textures.size(); ++i)
	{
		frames[i] = sf::FloatRect(0, 0, textures[i].getSize().x, textures[i].getSize().y);
	}

	int maxSize = sf::Texture::getMaximumSize();
	PowerOfTwoBinPacker packer(maxSize, maxSize);
	if (!packer.process(frames))
	{
		err << "Failed generating metatexture. Your graphics card may have a too low maximal texture size." << endl;
	}

	tex.create(packer.width(), packer.height());

	for (unsigned int i = 0; i < textures.size(); ++i)
	{
		sf::Sprite currentTex;
		currentTex.setTexture(textures[i]);
		currentTex.setPosition(frames[i].left, frames[i].top);
		tex.draw(currentTex);
	}

	tex.display();
}
示例#2
0
void Filter::unpackMsg(Message &msg) 
{
    Packer packer(msg.getContentBuf());

    info.filter_id = packer.unpackInt();
    info.so_file = packer.unpackStr();
}
示例#3
0
// Save: write the given CModelDef to the given file
void CModelDef::Save(const VfsPath& filename, const CModelDef* mdef)
{
	CFilePacker packer(FILE_VERSION, "PSMD");

	// pack everything up
	const size_t numVertices = mdef->GetNumVertices();
	packer.PackSize(numVertices);
	packer.PackRaw(mdef->GetVertices(), sizeof(SModelVertex) * numVertices);

	const size_t numFaces = mdef->GetNumFaces();
	packer.PackSize(numFaces);
	packer.PackRaw(mdef->GetFaces(), sizeof(SModelFace) * numFaces);
	
	const size_t numBones = mdef->m_NumBones;
	packer.PackSize(numBones);
	if (numBones)
		packer.PackRaw(mdef->m_Bones, sizeof(CBoneState) * numBones);

	const size_t numPropPoints = mdef->m_PropPoints.size();
	packer.PackSize(numPropPoints);
	for (size_t i = 0; i < numPropPoints; i++)
	{
		packer.PackString(mdef->m_PropPoints[i].m_Name);
		packer.PackRaw(&mdef->m_PropPoints[i].m_Position.X, sizeof(mdef->m_PropPoints[i].m_Position));
		packer.PackRaw(&mdef->m_PropPoints[i].m_Rotation.m_V.X, sizeof(mdef->m_PropPoints[i].m_Rotation));
		packer.PackRaw(&mdef->m_PropPoints[i].m_BoneIndex, sizeof(mdef->m_PropPoints[i].m_BoneIndex));
	}
	
	// flush everything out to file
	packer.Write(filename);
}
示例#4
0
std::unique_ptr<std::vector<char>> Format::pack(
        Data::PooledStack dataStack,
        const ChunkType chunkType) const
{
    std::unique_ptr<std::vector<char>> data;
    const std::size_t numPoints(dataStack.size());
    const std::size_t pointSize(schema().pointSize());

    if (m_compress)
    {
        Compressor compressor(m_metadata.schema(), dataStack.size());
        for (const char* pos : dataStack) compressor.push(pos, pointSize);
        data = compressor.data();
    }
    else
    {
        data = makeUnique<std::vector<char>>();
        data->reserve(numPoints * pointSize);
        for (const char* pos : dataStack)
        {
            data->insert(data->end(), pos, pos + pointSize);
        }
    }

    assert(data);
    dataStack.reset();

    Packer packer(m_tailFields, *data, numPoints, chunkType);
    append(*data, packer.buildTail());

    return data;
}
示例#5
0
void DeltaProcess::deoptimize_stretch(frame* first_frame, frame* last_frame) {
  if (TraceDeoptimization) {
    std->print_cr("[Deoptimizing]");
    frame c = *first_frame;
    c.print_for_deoptimization(std);
    while (c.fp() != last_frame->fp()) {
      c = c.sender();
      c.print_for_deoptimization(std);
    }
  }

  StackChunkBuilder packer(first_frame->fp());

  vframe* vf = vframe::new_vframe(first_frame);
  assert(vf->is_compiled_frame(), "must be Delta frame");

  for (deltaVFrame* current = (deltaVFrame*) vf; 
       current && (current->fr().fp() <= last_frame->fp()); 
       current = (deltaVFrame*) current->sender()) {
    packer.append(current);
  }

  // Patch frame
  // - patch the pc first to convert the frame into a deoptimized_frame
  first_frame->patch_pc((char*) &unpack_unoptimized_frames); 
  first_frame->set_return_addr(last_frame->return_addr());
  first_frame->set_real_sender_sp(last_frame->sender_sp());
  first_frame->set_frame_array(packer.as_objArray());
  first_frame->set_link(last_frame->link());
}
示例#6
0
///////////////////////////////////////////////////////////////////////////////////////////////////
// SaveMap: try to save the current map to the given file
void CMapWriter::SaveMap(const VfsPath& pathname, CTerrain* pTerrain,
						 WaterManager* pWaterMan, SkyManager* pSkyMan,
						 CLightEnv* pLightEnv, CCamera* pCamera, CCinemaManager* pCinema,
						 CPostprocManager* pPostproc,
						 CSimulation2* pSimulation2)
{
	CFilePacker packer(FILE_VERSION, "PSMP");

	// build necessary data
	PackMap(packer, pTerrain);

	try
	{
		// write it out
		packer.Write(pathname);
	}
	catch (PSERROR_File_WriteFailed&)
	{
		LOGERROR("Failed to write map '%s'", pathname.string8());
		return;
	}

	VfsPath pathnameXML = pathname.ChangeExtension(L".xml");
	WriteXML(pathnameXML, pWaterMan, pSkyMan, pLightEnv, pCamera, pCinema, pPostproc, pSimulation2);
}
示例#7
0
void
MsgTalk :: create(const Player& aSpeaker, const Player& aHearer, const char* aEmotion,
                  const char* aWords, Channel aChannel, uint32_t aColor)
{
    ASSERT(&aSpeaker != nullptr && &aHearer != nullptr);
    ASSERT(aSpeaker.getName() != nullptr && aSpeaker.getName()[0] != '\0');
    ASSERT(aHearer.getName() != nullptr && aHearer.getName()[0] != '\0');
    ASSERT(aEmotion != nullptr);
    ASSERT(aWords != nullptr && aWords[0] != '\0');

    if (strlen(aSpeaker.getName()) < MAX_NAMESIZE &&
        strlen(aHearer.getName()) < MAX_NAMESIZE &&
        strlen(aEmotion) < MAX_NAMESIZE &&
        strlen(aWords) < MAX_WORDSSIZE)
    {
        mInfo->Header.Length = mLen;
        mInfo->Header.Type = MSG_TALK;

        mInfo->Color = aColor;
        mInfo->Channel = (uint16_t)aChannel;
        mInfo->Style = (int16_t)STYLE_NORMAL;
        mInfo->Timestamp = timeGetTime();

        StringPacker packer(mInfo->Buf);
        packer.addString(aSpeaker.getName());
        packer.addString(aHearer.getName());
        packer.addString(aEmotion);
        packer.addString(aWords);
    }
    else
    {
        LOG(ERROR, "Invalid length: hearer=%zu, speaker=%zu, emotion=%zu, words=%zu",
            strlen(aHearer.getName()), strlen(aSpeaker.getName()), strlen(aEmotion), strlen(aWords));
    }
}
示例#8
0
文件: BinModule.cpp 项目: lrog/orcom
void BinModule::Bin2Dna(const std::string &inBinFile_, const std::string &outDnaFile_)
{
	// TODO: try/catch to free resources
	//
	BinFileReader binFile;

	binFile.StartDecompress(inBinFile_, config);
	uint32 minimizersCount = config.minimizer.TotalMinimizersCount();

	DnaFileWriter dnaFile(outDnaFile_);
	DataChunk fastqChunk(config.fastqBlockSize >> 1);			// WARNING! --- here can be a BUG
	DnaPacker packer(config.minimizer);
	DnaParser parser;

	DnaBinBlock dnaBins(minimizersCount);
	BinaryBinBlock binBins;
	DataChunk dnaBuffer;

	while (binFile.ReadNextBlock(&binBins))
	{
		packer.UnpackFromBins(binBins, dnaBins, dnaBuffer);
		parser.ParseTo(dnaBins, fastqChunk);

		dnaFile.WriteNextChunk(&fastqChunk);
	}

	dnaFile.Close();
	binFile.FinishDecompress();
}
示例#9
0
	bool compute_screen_layout (const pair & vscreen_min_size, const pair & vscreen_max_size, const pair_list & screen_sizes, const setting & user_constraints, pair & vscreen_size, pair_list & screen_positions) {
		int nb_screen = screen_sizes.size ();
		const long init = std::numeric_limits< long >::max ();
		long last_objective = init;

		// Iterate over layout templates
		sequence_pair seq_pair (nb_screen);
		do {
			// Compare layout template to user constraints
			int ok = 1;
			for (int sa = 0; ok && sa < nb_screen; ++sa)
				for (int sb = 0; ok && sb < sa; ++sb)
					ok = user_constraints[sa][sb] == none || user_constraints[sa][sb] == seq_pair.ordering (sa, sb);

			if (ok) {
				// Compute positions	
				rectangle_packer packer (nb_screen, vscreen_min_size, vscreen_max_size, screen_sizes, seq_pair);
				if (packer.solve ()) {
					long objective = packer.objective ();
					pair virtual_screen_size = packer.virtual_screen ();

					// Record solution only if better objective (and smaller)
					if (objective < last_objective || (objective == last_objective && virtual_screen_size < vscreen_size)) {
						last_objective = objective;
						vscreen_size = virtual_screen_size;
						screen_positions = packer.screen_positions ();
					}
				}
			}
		} while (seq_pair.next ());
		return last_objective != init;
	}
示例#10
0
TEST_F(nearest_neighbor_test, save_load) {
  {
    core::fv_converter::datum d;
    d.string_values_.push_back(std::make_pair("k1", "val"));
    nearest_neighbor_->set_row("1", d);
  }

  // save to a buffer
  msgpack::sbuffer sbuf;
  msgpack::packer<msgpack::sbuffer> packer(sbuf);
  nearest_neighbor_->get_mixable_holder()->pack(packer);

  // restart the driver
  TearDown();
  SetUp();

  // unpack the buffer
  msgpack::unpacked unpacked;
  msgpack::unpack(&unpacked, sbuf.data(), sbuf.size());
  nearest_neighbor_->get_mixable_holder()->unpack(unpacked.get());

  std::vector<std::pair<std::string, float> > res
      = nearest_neighbor_->similar_row("1", 1);
  ASSERT_EQ(1u, res.size());
  EXPECT_EQ("1", res[0].first);
}
示例#11
0
/** @return Glyph package containing glyphs for font. */
GlyphPackage GlyphTexture::makePackage(const Font &font) {
	
	GlyphPacker packer(font);
	
	packer.pack();
	return packer.getPackage();
}
示例#12
0
void
MsgDialog :: create(const char* aText, uint16_t aData,
                    uint8_t aIdxTask, Action aAction)
{
    ASSERT(aText != nullptr && aText[0] != '\0');

    if (strlen(aText) < MAX_PARAMSIZE)
    {
        mInfo->Header.Length = mLen;
        mInfo->Header.Type = MSG_DIALOG;

        mInfo->PosX = 0;
        mInfo->PosY = 0;
        mInfo->Data = aData;
        mInfo->IdxTask = aIdxTask;
        mInfo->Action = (uint8_t)aAction;

        StringPacker packer(mInfo->Buf);
        packer.addString(aText);
    }
    else
    {
        LOG(ERROR, "Invalid length: text=%zu",
            strlen(aText));
    }
}
示例#13
0
void SoapyRemoteDevice::closeStream(SoapySDR::Stream *stream)
{
    auto data = (ClientStreamData *)stream;

    std::lock_guard<std::mutex> lock(_mutex);
    SoapyRPCPacker packer(_sock);
    packer & SOAPY_REMOTE_CLOSE_STREAM;
    packer & data->streamId;
    packer();

    SoapyRPCUnpacker unpacker(_sock);

    //cleanup local stream data
    delete data->endpoint;
    delete data;
}
示例#14
0
void MessagePackAdaptorTests::testInvalidType() {
    msgpack::packer<msgpack::sbuffer> packer(buffer);
    const std::string value("abc 123");
    packer.pack_ext(value.size(), 12);
    packer.pack_ext_body(value.data(), value.size());
    auto o = unpack();
    CPPUNIT_ASSERT_EQUAL( msgpack::type::EXT, o.type );
    CPPUNIT_ASSERT_THROW( o.as<Datum>(), msgpack::type_error );
}
void RectangleUtils::pack(RectanglePointers& rects,
                          const ofRectangle& boundingRect)
{
    ofRectanglePacker packer(boundingRect, 0);

    for(size_t i = 0; i < rects.size(); i++)
    {
        if (!packer.pack(*rects[i])) return;
    }
}
示例#16
0
int SoapyRemoteDevice::deactivateStream(
    SoapySDR::Stream *stream,
    const int flags,
    const long long timeNs)
{
    auto data = (ClientStreamData *)stream;

    std::lock_guard<std::mutex> lock(_mutex);
    SoapyRPCPacker packer(_sock);
    packer & SOAPY_REMOTE_DEACTIVATE_STREAM;
    packer & data->streamId;
    packer & flags;
    packer & timeNs;
    packer();

    SoapyRPCUnpacker unpacker(_sock);
    int result = 0;
    unpacker & result;
    return result;
}
示例#17
0
		void optimize(std::shared_ptr<library::XML> xml)
		{
			std::shared_ptr<packer::Packer> packer(new packer::Packer());
			packer->construct(xml);

			auto invoke = std::make_shared<protocol::Invoke>("optimizePacker", packer->toXML());
			size_t size = library::CombinedPermutationGenerator(packer->size(), packer->productSize()).size();

			std::cout << "Start Packer optimization: #" << size << std::endl;
			init(size);
		};
示例#18
0
    encoded(uint64_t span, Args&&... args) {
        msgpack::packer<aux::encoded_buffers_t> packer(buffer);

        packer.pack_array(3);

        packer.pack_uint64(span);
        packer.pack_uint32(event_traits<Event>::id);

        typedef typename event_traits<Event>::argument_type argument_type;

        type_traits<argument_type>::pack(packer, std::forward<Args>(args)...);
    }
示例#19
0
int main(int argc, const char **argv) try
{
    if (argc != 3)
        throw std::runtime_error("Invalid input. Usage: atlas_packer.exe params.json output.json");

    auto jsonRoot = ReadInput(argv[1]);

    int width = jsonRoot["size"][0].asInt();
    int height = jsonRoot["size"][1].asInt();

    rbp::MaxRectsBinPack packer(width, height, false);

    std::vector<rbp::Rect> resultRects;

    for (auto it : jsonRoot["inputRects"])
    {
        int rectWidth = it[0].asInt();
        int rectHeight = it[1].asInt();

        auto rect = packer.Insert(rectWidth, rectHeight, rbp::MaxRectsBinPack::FreeRectChoiceHeuristic::RectBestAreaFit);
        if ((rect.height > 0) && (rect.width == rectWidth) && (rect.height == rectHeight))
            resultRects.push_back(rect);
        else
            throw std::runtime_error("Atlas Packer: failed to pack");
    }

    Json::Value result;
    result["rects"] = Json::Value(Json::arrayValue);
    for (auto r : resultRects)
    {
        Json::Value jsonRect;
        jsonRect["x"] = r.x;
        jsonRect["y"] = r.y;
        jsonRect["w"] = r.width;
        jsonRect["h"] = r.height;

        result["rects"].append(jsonRect);
    }

    std::ofstream outf(argv[2]);
    Json::StreamWriterBuilder b;
    b["indentation"] = "  ";
    outf << Json::writeString(b, result);

    return outf.bad() ? 1 : 0;
}
catch (std::exception &e)
{
    std::cerr << "An error occurred:\n" << e.what() << "\n";

    return 1;
}
示例#20
0
void indri::net::NetworkServerStub::_handleQuery( indri::xml::XMLNode* request ) {
  indri::lang::Unpacker unpacker(request);
  std::vector<indri::lang::Node*> nodes = unpacker.unpack();
  int resultsRequested = (int) string_to_i64( request->getAttribute( "resultsRequested" ) );
  bool optimize = request->getAttribute("optimize") == "1";

  indri::server::QueryServerResponse* response = _server->runQuery( nodes, resultsRequested, optimize );
  indri::infnet::InferenceNetwork::MAllResults results = response->getResults();

  QueryResponsePacker packer( results );
  packer.write( _stream );
  delete response;
}
示例#21
0
static void packer_table(lua_State *L, CTX *ctx, int obj_index)
{
  lua_rawgeti(L, ctx->index, CTX_INDEX_TABLE_IDXS);
  lua_pushvalue(L, obj_index);
  lua_rawget(L, -2);

  if (lua_isnil(L, -1))
  {
    lua_rawgeti(L, ctx->index, CTX_INDEX_TABLES);
    lua_pushvalue(L, obj_index);
    lua_rawseti(L, -2, ++ctx->table_count);

    lua_rawgeti(L, ctx->index, CTX_INDEX_TABLE_IDXS);
    lua_pushvalue(L, obj_index);
    lua_pushinteger(L, ctx->table_count);
    lua_rawset(L, -3);

    // pop CTX_INDEX_TABLES & CTX_INDEX_TABLE_IDXS
    lua_pop(L, 2);
  }
  else
  {
    lua_pop(L, 2);
    return;
  }

  lua_pop(L, 2);

  lua_pushnil(L);
  while (lua_next(L, obj_index) != 0)
  {
    int value_idx = lua_gettop(L);
    int key_idx = lua_gettop(L) - 1;

    packer(L, ctx, key_idx);
    packer(L, ctx, value_idx);
    lua_pop(L, 1);
  }
}
示例#22
0
TEST(Header, Marshal) {
  yyproto::Header header;
  header.length = 10;
  header.id = 42;
  header.code = 200;

  yyproto::ByteBuffer buffer;
  EXPECT_EQ(buffer.Size(), static_cast<size_t>(0));

  yyproto::Packer packer(&buffer);
  header.Marshal(&packer);
  EXPECT_EQ(buffer.Size(), static_cast<size_t>(10));
}
TEST(inverted_index_storage, trivial) {
  inverted_index_storage s;
  // r1: (1, 1, 1, 0, 0)
  s.set("c1", "r1", 1);
  s.set("c2", "r1", 1);
  s.set("c3", "r1", 1);
  // r2: (1, 0, 1, 1, 0)
  s.set("c1", "r2", 1);
  s.set("c3", "r2", 1);
  s.set("c4", "r2", 1);
  // r3: (0, 1, 0, 0, 1)
  s.set("c2", "r3", 1);
  s.set("c5", "r3", 1);

  // v:  (1, 1, 0, 0, 0)
  common::sfv_t v;
  v.push_back(make_pair("c1", 1.0));
  v.push_back(make_pair("c2", 1.0));

  vector<pair<string, double> > scores;
  s.calc_scores(v, scores, 100);

  ASSERT_EQ(3u, scores.size());
  EXPECT_DOUBLE_EQ(2.0 / std::sqrt(3) / std::sqrt(2), scores[0].second);
  EXPECT_EQ("r1", scores[0].first);
  EXPECT_DOUBLE_EQ(1.0 / std::sqrt(2) / std::sqrt(2), scores[1].second);
  EXPECT_EQ("r3", scores[1].first);
  EXPECT_DOUBLE_EQ(1.0 / std::sqrt(2) / std::sqrt(3), scores[2].second);
  EXPECT_EQ("r2", scores[2].first);

  msgpack::sbuffer buf;
  framework::stream_writer<msgpack::sbuffer> st(buf);
  framework::jubatus_packer jp(st);
  framework::packer packer(jp);
  s.pack(packer);
  inverted_index_storage s2;
  msgpack::unpacked unpacked;
  msgpack::unpack(&unpacked, buf.data(), buf.size());
  s2.unpack(unpacked.get());
  vector<pair<string, double> > scores2;
  s.calc_scores(v, scores2, 100);
  // expect to get same result
  ASSERT_EQ(3u, scores2.size());
  EXPECT_DOUBLE_EQ(2.0 / std::sqrt(3) / std::sqrt(2), scores2[0].second);
  EXPECT_EQ("r1", scores2[0].first);
  EXPECT_DOUBLE_EQ(1.0 / std::sqrt(2) / std::sqrt(2), scores2[1].second);
  EXPECT_EQ("r3", scores2[1].first);
  EXPECT_DOUBLE_EQ(1.0 / std::sqrt(2) / std::sqrt(3), scores2[2].second);
  EXPECT_EQ("r2", scores2[2].first);
}
示例#24
0
/***********************************************************************
 * Transaction handler
 **********************************************************************/
bool SoapyClientHandler::handleOnce(void)
{
    if (not _sock.selectRecv(SOAPY_REMOTE_SOCKET_TIMEOUT_US)) return true;

    //receive the client's request
    SoapyRPCUnpacker unpacker(_sock);
    SoapyRPCPacker packer(_sock);

    //handle the client's request
    bool again = true;
    try
    {
        again = this->handleOnce(unpacker, packer);
    }
    catch (const std::exception &ex)
    {
        packer & ex;
    }

    //send the result back
    packer();

    return again;
}
示例#25
0
LUA_API int luafan_objectbuf_symbol(lua_State *L)
{
  if (lua_gettop(L) == 0)
  {
    luaL_error(L, "no argument.");
  }

  CTX ctx = {0};
  ctx_init(&ctx, L);

  packer(L, &ctx, 1);

  lua_settop(L, ctx.index);
  return 1;
}
示例#26
0
static ResUICallback MakeUICallback(fx::Resource* resource, const std::string& type)
{
	return [=] (const std::string& postData, ResUIResultCallback cb)
	{
		// get the event component
		fwRefContainer<fx::ResourceEventComponent> eventComponent = resource->GetComponent<fx::ResourceEventComponent>();
		fwRefContainer<ResourceUICallbackComponent> callbacks;
		fwRefContainer<ResourceUI> ui = resource->GetComponent<ResourceUI>();

		if (!ui->HasCallbacks())
		{
			callbacks = new ResourceUICallbackComponent(resource);
			resource->SetComponent(callbacks);

			ui->SetHasCallbacks(true);
		}
		else
		{
			callbacks = resource->GetComponent<ResourceUICallbackComponent>();
		}

		// generate a reference for the result
		std::string reference = callbacks->GetScriptRuntime()->AddCallbackRef(cb);

		// trigger the event with the contained payload
		msgpack::sbuffer buffer;
		msgpack::packer<msgpack::sbuffer> packer(buffer);

		// serialize the post object JSON as a msgpack object
		rapidjson::Document postJSON;
		postJSON.Parse(postData.c_str());

		if (!postJSON.HasParseError())
		{
			msgpack::object postObject;
			msgpack::zone zone;
			ConvertToMsgPack(postJSON, postObject, zone);

			// pack an array of arguments ([postData, cb])
			packer.pack_array(2).
				pack(postObject).
				pack_ext(reference.size(), 10).
					pack_ext_body(reference.c_str(), reference.size());

			eventComponent->QueueEvent("__cfx_nui:" + type, std::string(buffer.data(), buffer.size()), "nui");
		}
	};
}
示例#27
0
文件: nxtd.c 项目: jgraef/aNXT
/**
 * Lists all NXTs that are connected via BT
 *  @param packer Packer function
 */
static void nxtd_list(void (*packer)(int handle, char *name, void *id, int is_bt)) {
  size_t i;

  pthread_mutex_lock(&nxts.mutex);
  for (i=0;i<NXTD_MAXNUM;i++) {
    if (nxts.list[i]!=NULL) {
      if (nxtd_keepalive(nxts.list[i])==0) {
        packer(i, nxts.list[i]->name, nxts.list[i]->id, nxts.list[i]->conn_type==NXTD_BT);
      }
      else {
        nxtd_nxt_remove(i);
      }
    }
  }
  pthread_mutex_unlock(&nxts.mutex);
}
示例#28
0
void
MsgDialog :: process(Client* aClient)
{
    ASSERT(aClient != nullptr);
    ASSERT(aClient->getPlayer() != nullptr);

    Client& client = *aClient;
    Player& player = *aClient->getPlayer();

    if (!player.isAlive())
    {
        player.sendSysMsg(STR_DIE);
        return;
    }

    char text[MAX_PARAMSIZE];

    StringPacker packer(mInfo->Buf);
    packer.getString(text, sizeof(text), 0);

    fprintf(stderr, "MsgDialog(action=%u, idx=%u, data=%u, str='%s')\n",
            mInfo->Action, mInfo->IdxTask, mInfo->Data, text);

    switch (mInfo->Action)
    {
    case ACTION_ANSWER:
        {
            //player.processTask(info->IdxTask, text);
            break;
        }
    case ACTION_TASKID:
        {
            //player.processClientTask(info->TaskId, text);
            break;
        }
    default:
        {
            fprintf(stdout, "Unknown event[%04u], data=[%d]\n",
                    mInfo->Action, mInfo->IdxTask);
            break;
        }
//    default:
//        ASSERT(false);
//        break;
    }
}
示例#29
0
void save_server(FILE* fp,
    const server_base& server, const std::string& id) {
  init_versions();

  msgpack::sbuffer system_data_buf;
  msgpack::pack(&system_data_buf, system_data_container(server, id));

  msgpack::sbuffer user_data_buf;
  {
    core::framework::stream_writer<msgpack::sbuffer> st(user_data_buf);
    core::framework::jubatus_packer jp(st);
    core::framework::packer packer(jp);
    packer.pack_array(2);

    uint64_t user_data_version = server.user_data_version();
    packer.pack(user_data_version);
    server.get_driver()->pack(packer);
  }

  char header_buf[48];
  std::memcpy(header_buf, magic_number, 8);
  write_big_endian(format_version, &header_buf[8]);
  write_big_endian(jubatus_version_major, &header_buf[16]);
  write_big_endian(jubatus_version_minor, &header_buf[20]);
  write_big_endian(jubatus_version_maintenance, &header_buf[24]);
  // write_big_endian(crc32, &header_buf[28]);  // skipped
  write_big_endian(static_cast<uint64_t>(system_data_buf.size()),
                   &header_buf[32]);
  write_big_endian(static_cast<uint64_t>(user_data_buf.size()),
                   &header_buf[40]);

  uint32_t crc32 = calc_crc32(header_buf,
      system_data_buf.data(), system_data_buf.size(),
      user_data_buf.data(), user_data_buf.size());
  write_big_endian(crc32, &header_buf[28]);

  if (!fwrite_helper(header_buf, sizeof(header_buf), fp)) {
    throw std::ios_base::failure("Failed to write header_buf.");
  }
  if (!fwrite_helper(system_data_buf.data(), system_data_buf.size(), fp)) {
    throw std::ios_base::failure("Failed to write system_data_buf.");
  }
  if (!fwrite_helper(user_data_buf.data(), user_data_buf.size(), fp)) {
    throw std::ios_base::failure("Failed to write user_data_buf.");
  }
}
示例#30
0
///////////////////////////////////////////////////////////////////////////////////////////////////
// SaveMap: try to save the current map to the given file
void CMapWriter::SaveMap(const VfsPath& pathname, CTerrain* pTerrain,
						 WaterManager* pWaterMan, SkyManager* pSkyMan,
						 CLightEnv* pLightEnv, CCamera* pCamera, CCinemaManager* pCinema,
						 CPostprocManager* pPostproc,
						 CSimulation2* pSimulation2)
{
	CFilePacker packer(FILE_VERSION, "PSMP");

	// build necessary data
	PackMap(packer, pTerrain);

	// write it out
	packer.Write(pathname);

	VfsPath pathnameXML = pathname.ChangeExtension(L".xml");
	WriteXML(pathnameXML, pWaterMan, pSkyMan, pLightEnv, pCamera, pCinema, pPostproc, pSimulation2);
}