本文整理汇总了C++中sp_ctof函数的典型用法代码示例。如果您正苦于以下问题:C++ sp_ctof函数的具体用法?C++ sp_ctof怎么用?C++ sp_ctof使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sp_ctof函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: smn_PbSetVector2D
static cell_t smn_PbSetVector2D(IPluginContext *pCtx, const cell_t *params)
{
GET_MSG_FROM_HANDLE_OR_ERR();
GET_FIELD_NAME_OR_ERR();
cell_t *vecParams;
if ((err=pCtx->LocalToPhysAddr(params[3], &vecParams)) != SP_ERROR_NONE)
{
pCtx->ThrowNativeErrorEx(err, NULL);
return 0;
}
Vector2D vec(
sp_ctof(vecParams[0]),
sp_ctof(vecParams[1]));
int index = params[0] >= 4 ? params[4] : -1;
if (index < 0)
{
if (!msg->SetVector2D(strField, vec))
{
return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str());
}
}
else
{
if (!msg->SetRepeatedVector2D(strField, index, vec))
{
return pCtx->ThrowNativeError("Invalid field \"%s\"[%d] for message \"%s\"", strField, index, msg->GetProtobufMessage()->GetTypeName().c_str());
}
}
return 1;
}
示例2: smn_TEWriteVector
static cell_t smn_TEWriteVector(IPluginContext *pContext, const cell_t *params)
{
if (!g_TEManager.IsAvailable())
{
return pContext->ThrowNativeError("TempEntity System unsupported or not available, file a bug report");
}
if (!g_CurrentTE)
{
return pContext->ThrowNativeError("No TempEntity call is in progress");
}
char *prop;
pContext->LocalToString(params[1], &prop);
cell_t *addr;
pContext->LocalToPhysAddr(params[2], &addr);
float vec[3] = {sp_ctof(addr[0]), sp_ctof(addr[1]), sp_ctof(addr[2])};
if (!g_CurrentTE->TE_SetEntDataVector(prop, vec))
{
return pContext->ThrowNativeError("Temp entity property \"%s\" not found", prop);
}
return 1;
}
示例3: GetClientsInRange
static cell_t GetClientsInRange(IPluginContext *pContext, const cell_t *params)
{
cell_t *origin;
pContext->LocalToPhysAddr(params[1], &origin);
Vector vOrigin(sp_ctof(origin[0]), sp_ctof(origin[1]), sp_ctof(origin[2]));
ClientRangeType rangeType = (ClientRangeType) params[2];
CBitVec<ABSOLUTE_PLAYER_LIMIT> players;
engine->Message_DetermineMulticastRecipients(rangeType == ClientRangeType::Audibility, vOrigin, players);
cell_t *outPlayers;
pContext->LocalToPhysAddr(params[3], &outPlayers);
int maxPlayers = params[4];
int curPlayers = 0;
int index = players.FindNextSetBit(0);
while (index > -1 && curPlayers < maxPlayers)
{
int entidx = index + 1;
CPlayer *pPlayer = g_Players.GetPlayerByIndex(entidx);
if (pPlayer && pPlayer->IsInGame())
{
outPlayers[curPlayers++] = entidx;
}
index = players.FindNextSetBit(index + 1);
}
return curPlayers;
}
示例4: EmitAmbientSound
static cell_t EmitAmbientSound(IPluginContext *pContext, const cell_t *params)
{
cell_t entity;
Vector pos;
char *name;
float vol, delay;
int pitch, flags, level;
entity = SoundReferenceToIndex(params[3]);
cell_t *addr;
pContext->LocalToPhysAddr(params[2], &addr);
pos.x = sp_ctof(addr[0]);
pos.y = sp_ctof(addr[1]);
pos.z = sp_ctof(addr[2]);
pContext->LocalToString(params[1], &name);
vol = sp_ctof(params[6]);
level = params[4];
flags = params[5];
pitch = params[7];
delay = sp_ctof(params[8]);
if (g_InSoundHook)
{
ENGINE_CALL(EmitAmbientSound)(entity, pos, name, vol, (soundlevel_t)level, flags, pitch, delay);
}
else
{
engine->EmitAmbientSound(entity, pos, name, vol, (soundlevel_t)level, flags, pitch, delay);
}
return 1;
}
示例5: FadeClientVolume
static cell_t FadeClientVolume(IPluginContext *pContext, const cell_t *params)
{
int client = params[1];
if (client < 1 || client > playerhelpers->GetMaxClients())
{
return pContext->ThrowNativeError("Client index %d is not valid", client);
}
IGamePlayer *player = playerhelpers->GetGamePlayer(client);
if (!player->IsInGame())
{
return pContext->ThrowNativeError("Client index %d is not in game", client);
}
engine->FadeClientVolume(
#if SOURCE_ENGINE == SE_DOTA
player->GetIndex(),
#else
player->GetEdict(),
#endif
sp_ctof(params[2]),
sp_ctof(params[3]),
sp_ctof(params[4]),
sp_ctof(params[5]));
return 1;
}
示例6: sm_SetConVarBounds
static cell_t sm_SetConVarBounds(IPluginContext *pContext, const cell_t *params)
{
Handle_t hndl = static_cast<Handle_t>(params[1]);
HandleError err;
ConVar *pConVar;
if ((err=g_ConVarManager.ReadConVarHandle(hndl, &pConVar))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid convar handle %x (error %d)", hndl, err);
}
switch (params[2])
{
case ConVarBound_Upper:
pConVar->SetMax(params[3] ? true : false, sp_ctof(params[4]));
break;
case ConVarBound_Lower:
pConVar->SetMin(params[3] ? true : false, sp_ctof(params[4]));
break;
default:
return pContext->ThrowNativeError("Invalid ConVarBounds value %d");
}
return 1;
}
示例7: sm_CreateConVar
static cell_t sm_CreateConVar(IPluginContext *pContext, const cell_t *params)
{
char *name, *defaultVal, *helpText;
pContext->LocalToString(params[1], &name);
// While the engine seems to accept a blank convar name, it causes a crash upon server quit
if (name == NULL || strcmp(name, "") == 0)
{
return pContext->ThrowNativeError("Convar with blank name is not permitted");
}
pContext->LocalToString(params[2], &defaultVal);
pContext->LocalToString(params[3], &helpText);
bool hasMin = params[5] ? true : false;
bool hasMax = params[7] ? true : false;
float min = sp_ctof(params[6]);
float max = sp_ctof(params[8]);
Handle_t hndl = g_ConVarManager.CreateConVar(pContext, name, defaultVal, helpText, params[4], hasMin, min, hasMax, max);
if (hndl == BAD_HANDLE)
{
return pContext->ThrowNativeError("Convar \"%s\" was not created. A console command with the same might already exist.", name);
}
return hndl;
}
示例8: smn_KvSetVector
static cell_t smn_KvSetVector(IPluginContext *pCtx, const cell_t *params)
{
Handle_t hndl = static_cast<Handle_t>(params[1]);
HandleError herr;
HandleSecurity sec;
KeyValueStack *pStk;
sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent;
if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None)
{
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
}
char *key;
char buffer[64];
cell_t *vector;
pCtx->LocalToStringNULL(params[2], &key);
pCtx->LocalToPhysAddr(params[3], &vector);
UTIL_Format(buffer, sizeof(buffer), "%f %f %f", sp_ctof(vector[0]), sp_ctof(vector[1]), sp_ctof(vector[2]));
pStk->pCurRoot.front()->SetString(key, buffer);
return 1;
}
示例9: sm_Pow
static cell_t sm_Pow(IPluginContext *pCtx, const cell_t *params)
{
float base = sp_ctof(params[1]);
float exponent = sp_ctof(params[2]);
return sp_ftoc(pow(base, exponent));
}
示例10: smn_TRGetPointContents
static cell_t smn_TRGetPointContents(IPluginContext *pContext, const cell_t *params)
{
cell_t *vec, *ent;
IHandleEntity *hentity;
Vector pos;
int mask;
pContext->LocalToPhysAddr(params[1], &vec);
pContext->LocalToPhysAddr(params[2], &ent);
pos.x = sp_ctof(vec[0]);
pos.y = sp_ctof(vec[1]);
pos.z = sp_ctof(vec[2]);
if (*ent == -1)
{
mask = enginetrace->GetPointContents(pos);
} else {
#if SOURCE_ENGINE >= SE_LEFT4DEAD || SOURCE_ENGINE == SE_BMS
mask = enginetrace->GetPointContents(pos, MASK_ALL, &hentity);
#else
mask = enginetrace->GetPointContents(pos, &hentity);
#endif
*ent = gamehelpers->EntityToBCompatRef(reinterpret_cast<CBaseEntity *>(hentity));
}
return mask;
}
示例11: sm_ArcTangent2
static cell_t sm_ArcTangent2(IPluginContext *pCtx, const cell_t *params)
{
float val1 = sp_ctof(params[1]);
float val2 = sp_ctof(params[2]);
val1 = atan2(val1, val2);
return sp_ftoc(val1);
}
示例12: GetRandomFloat
static cell_t GetRandomFloat(IPluginContext *pContext, const cell_t *params)
{
float fMin = sp_ctof(params[1]);
float fMax = sp_ctof(params[2]);
float fRandom = engrandom->RandomFloat(fMin, fMax);
return sp_ftoc(fRandom);
}
示例13: smn_TRTraceRay
static cell_t smn_TRTraceRay(IPluginContext *pContext, const cell_t *params)
{
cell_t *startaddr, *endaddr;
pContext->LocalToPhysAddr(params[1], &startaddr);
pContext->LocalToPhysAddr(params[2], &endaddr);
g_StartVec.Init(sp_ctof(startaddr[0]), sp_ctof(startaddr[1]), sp_ctof(startaddr[2]));
switch (params[4])
{
case RayType_EndPoint:
{
g_EndVec.Init(sp_ctof(endaddr[0]), sp_ctof(endaddr[1]), sp_ctof(endaddr[2]));
break;
}
case RayType_Infinite:
{
g_DirAngles.Init(sp_ctof(endaddr[0]), sp_ctof(endaddr[1]), sp_ctof(endaddr[2]));
AngleVectors(g_DirAngles, &g_EndVec);
/* Make it unitary and get the ending point */
g_EndVec.NormalizeInPlace();
g_EndVec = g_StartVec + g_EndVec * MAX_TRACE_LENGTH;
break;
}
}
g_Ray.Init(g_StartVec, g_EndVec);
enginetrace->TraceRay(g_Ray, params[3], &g_HitAllFilter, &g_Trace);
g_Trace.UpdateEntRef();
return 1;
}
示例14: sp_ftoc
void SoundHooks::OnEmitAmbientSound(CEntityIndex index, const Vector &pos, const char *samp, float vol,
soundlevel_t soundlevel, int fFlags, int pitch, float delay)
{
int entindex = index.Get();
#else
void SoundHooks::OnEmitAmbientSound(int entindex, const Vector &pos, const char *samp, float vol,
soundlevel_t soundlevel, int fFlags, int pitch, float delay)
{
#endif
SoundHookIter iter;
IPluginFunction *pFunc;
cell_t vec[3] = {sp_ftoc(pos.x), sp_ftoc(pos.y), sp_ftoc(pos.z)};
cell_t res = static_cast<ResultType>(Pl_Continue);
char buffer[PLATFORM_MAX_PATH];
strcpy(buffer, samp);
for (iter=m_AmbientFuncs.begin(); iter!=m_AmbientFuncs.end(); iter++)
{
pFunc = (*iter);
pFunc->PushStringEx(buffer, sizeof(buffer), SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK);
pFunc->PushCellByRef(&entindex);
pFunc->PushFloatByRef(&vol);
pFunc->PushCellByRef(reinterpret_cast<cell_t *>(&soundlevel));
pFunc->PushCellByRef(&pitch);
pFunc->PushArray(vec, 3, SM_PARAM_COPYBACK);
pFunc->PushCellByRef(&fFlags);
pFunc->PushFloatByRef(&delay);
g_InSoundHook = true;
pFunc->Execute(&res);
g_InSoundHook = false;
switch (res)
{
case Pl_Handled:
case Pl_Stop:
{
RETURN_META(MRES_SUPERCEDE);
}
case Pl_Changed:
{
Vector vec2;
vec2.x = sp_ctof(vec[0]);
vec2.y = sp_ctof(vec[1]);
vec2.z = sp_ctof(vec[2]);
#if SOURCE_ENGINE == SE_DOTA
RETURN_META_NEWPARAMS(MRES_IGNORED, &IVEngineServer::EmitAmbientSound,
(CEntityIndex(entindex), vec2, buffer, vol, soundlevel, fFlags, pitch, delay));
#else
RETURN_META_NEWPARAMS(MRES_IGNORED, &IVEngineServer::EmitAmbientSound,
(entindex, vec2, buffer, vol, soundlevel, fFlags, pitch, delay));
#endif
}
}
}
}
示例15: smn_TRPointOutsideWorld
static cell_t smn_TRPointOutsideWorld(IPluginContext *pContext, const cell_t *params)
{
cell_t *vec;
Vector pos;
pContext->LocalToPhysAddr(params[1], &vec);
pos.x = sp_ctof(vec[0]);
pos.y = sp_ctof(vec[1]);
pos.z = sp_ctof(vec[2]);
return enginetrace->PointOutsideWorld(pos);
}