예제 #1
0
파일: CJson.cpp 프로젝트: victorzjl/BPE
int CJsonEncoder::GetJsonStringLen()
{
	int nLen = 0;
	const char* pStr = (const char*)GetJsonString();
	if(pStr)
	{
		nLen = strlen(pStr);
	}
	return nLen;
}
void UCreatureAnimationAsset::GatherAnimationData()
{
	// ensure the filenames are synced
	creature_filename = GetCreatureFilename();
	
	// load the JSON data into creature so we can extract the animation names and generate the point caches for the anims
	CreatureCore creature_core;
	creature_core.pJsonData = &GetJsonString();
	creature_core.creature_filename = creature_filename;
	creature_core.InitCreatureRender();

	auto all_animation_names = creature_core.GetCreatureManager()->GetCreature()->GetAnimationNames();

	int32 arraySize = creature_core.GetCreatureManager()->GetCreature()->GetTotalNumPoints() * 3;

	m_pointsCache.Reset(all_animation_names.size());
	m_clipNames.Reset(all_animation_names.size());

	for (auto& cur_name : all_animation_names)
	{
		FString animName(cur_name.c_str());
		m_clipNames.Add(animName);

		if (m_pointsCacheApproximationLevel >= 0)
		{
			creature_core.GetCreatureManager()->ClearPointCache(cur_name);
			creature_core.GetCreatureManager()->MakePointCache(cur_name, m_pointsCacheApproximationLevel);
			CreatureModule::CreatureAnimation *anim = creature_core.GetCreatureManager()->GetAnimation(cur_name);
			if (ensure(anim) && anim->hasCachePts())
			{
				auto &pts = anim->getCachePts();

				FCreatureAnimationPointsCache &animPtsCache = m_pointsCache[m_pointsCache.AddZeroed(1)];
				animPtsCache.m_animationName = animName;
				animPtsCache.m_numArrays = pts.size();
				animPtsCache.m_points.Reserve(animPtsCache.m_numArrays * arraySize);

				for (float *pt : pts)
				{
					for (int32 i = 0; i < arraySize; i++)
					{
						animPtsCache.m_points.Add(pt[i]);
					}
				}
			}
		}
	}
}
예제 #3
0
int 
TestFormDataMP(HTTPClient* p_client)
{
  CString data = GetJsonString();

  MultiPartBuffer buffer(FD_MULTIPART);
  MultiPart* part1 = buffer.AddPart("json", "application/json",data);
  MultiPart* part2 = buffer.AddPart("empty","text/html",       ""); 
  MultiPart* part3 = buffer.AddFile("eventsource","application/js",file);

  // Test if we created all parts
  if(part1 == nullptr || part2 == nullptr || part3 == nullptr)
  {
    // --- "---------------------------------------------- - ------
    printf("MultiPartBuffer creation data+file check       : ERROR\n");
    return 1;
  }
  // Try to transport the filetimes to the server
  // BEWARE: Some servers do not respect the filetimes attributes
  //         or even crash on it (WCF .NET returns HTTP status 500)
  buffer.SetFileExtensions(true);

  CString url;
  url.Format("http://%s:%d/MarlinTest/FormData",MARLIN_HOST,TESTING_HTTP_PORT);
  HTTPMessage msg(HTTPCommand::http_post,url);
  msg.SetMultiPartFormData(&buffer);

  xprintf("TESTING FORM-DATA MULTPART BUFFER FUNCTION TO /MarlinTest/FormData\n");
  xprintf("==================================================================\n");
  bool result = p_client->Send(&msg);

  // SUMMARY OF THE TEST
  // --- "---------------------------------------------- - ------
  printf("Send: Multi-part form-data message             : %s\n",result ? "OK" : "ERROR");

  if(result == false)
  {
    CString error;
    p_client->GetError(&error);
    // SUMMARY OF THE TEST
    // --- "--------------------------- - ------\n"
    printf("HTTP ERROR                  : %s\n",(LPCTSTR)p_client->GetStatusText());
    printf("HTTP CLIENT Message         : %s\n",(LPCTSTR)error);
  }
  return result ? 0 : 1;
}