int Dynamo::PostReq(const std::string &op, const string &req) { // logdebug("req: \n%s", req.c_str()); // // char *ueReq = curl_easy_escape(curl, req.data(), (int) req.length()); // // if (NULL == ueReq) { // snprintf(lastErr, sizeof(lastErr), "curl_easy_escape failed"); // return -1; // } // // std::string data = ueReq; // curl_free (ueReq); if (0 != UpdateHead(op, req)) { return -1; } // logdebug("\ncommand=%s\nrequest=\n%s", op.c_str(), req.c_str()); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, req.c_str()); // curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, data.length()); strRsp.clear(); CURLcode code = curl_easy_perform(curl); if (CURLE_OK != code) { snprintf(lastErr, sizeof(lastErr), "%s", curl_easy_strerror(code)); return -1; } // logdebug("\ncommand=%s\nresponse=\n%s", op.c_str(), strRsp.c_str()); Document d; d.Parse<0>(strRsp.c_str()); if (d.HasParseError()) { snprintf(lastErr, sizeof(lastErr), "json doc parse failed, %u", d.GetParseError()); return -1; } rsp.SetNull(); allocator.Clear(); rsp.CopyFrom(d, allocator); if (rsp.HasMember("__type")) { snprintf(lastErr, sizeof(lastErr), "dynamo return error: %s", rsp.FindMember("__type")->value.GetString()); return -1; } return 0; }
void CPropVehicleManhack::UpdateManhackView( CBasePlayer *pPlayer ) { CNPC_Manhack *pManhack=GetManhack(); if (pManhack != NULL) { m_angManhackEye = pManhack->GetAbsAngles(); //vehicleEyeAngles; m_vecManhackEye = pManhack->GetManhackView(); //vehicleEyeOrigin; m_iManhackHealth = pManhack->m_iHealth; Vector vecDir = pManhack->GetAbsVelocity(); VectorNormalize(vecDir); m_vecFlyingDirection = vecDir; UpdateHead(); if (GlobalEntity_GetState("manhacks_use_short_distances") == GLOBAL_ON) { Vector vecDistance = (pManhack->GetAbsOrigin() - GetAbsOrigin()); float flHeight = vecDistance.z / manhack_small_distances_max_height.GetFloat(); vecDistance.z = 0.0f; vecDistance = vecDistance / manhack_small_distances_max_distance.GetFloat(); vecDistance.z = flHeight; m_iManhackDistance = (int)( vecDistance.Length() * 100.0f ); } else { m_iManhackDistance = (int)( (float) (pManhack->GetAbsOrigin() - GetAbsOrigin()).Length() / manhack_max_distance.GetFloat() * 100.0f); } if (m_iManhackDistance >= 90 && m_flLastWarningSound < gpGlobals->curtime ) { pManhack->EmitSound("NPC_Turret.Retire"); m_flLastWarningSound = gpGlobals->curtime + 1.00f; } // Vector vecForward; m_hPlayer->GetVectors(&vecForward, NULL, NULL); trace_t tr; UTIL_TraceLine( m_vecManhackEye, m_vecManhackEye + (vecForward * 1024), MASK_SHOT, pManhack, COLLISION_GROUP_NONE, &tr ); //NDebugOverlay::Line( m_vecManhackEye, tr.endpos, 255, 255, 0, true, 1.0f ); if (tr.m_pEnt && pPlayer && pPlayer->IRelationType( tr.m_pEnt ) == D_HT) { m_hTarget = tr.m_pEnt; } else { m_hTarget = pManhack->GetEnemy(); } m_iTargetType = HLSS_SelectTargetType(m_hTarget); } else { DevMsg("NULL Manhack\n"); m_hManhack = NULL; SetLocator( NULL ); } }