1.1 --- a/extensions/sdktools/outputnatives.cpp Fri Apr 25 00:08:27 2008 +0000
1.2 +++ b/extensions/sdktools/outputnatives.cpp Fri Apr 25 05:20:17 2008 +0000
1.3 @@ -268,342 +268,11 @@
1.4 return 0;
1.5 }
1.6
1.7 -#if 0
1.8 -static cell_t GetVariantType(IPluginContext *pContext, const cell_t *params)
1.9 -{
1.10 - Handle_t hndl = static_cast<Handle_t>(params[1]);
1.11 - HandleError err;
1.12 - varhandle_t *pInfo;
1.13 - HandleSecurity sec;
1.14 -
1.15 - sec.pOwner = NULL;
1.16 - sec.pIdentity = myself->GetIdentity();
1.17 -
1.18 - if ((err=handlesys->ReadHandle(hndl, g_OutputManager.VariantHandle, &sec, (void **)&pInfo))
1.19 - != HandleError_None)
1.20 - {
1.21 - return pContext->ThrowNativeError("Invalid variant handle %x (error %d)", hndl, err);
1.22 - }
1.23 -
1.24 - return pInfo->crab.FieldType();
1.25 -}
1.26 -
1.27 -static cell_t GetVariantInt(IPluginContext *pContext, const cell_t *params)
1.28 -{
1.29 - Handle_t hndl = static_cast<Handle_t>(params[1]);
1.30 - HandleError err;
1.31 - varhandle_t *pInfo;
1.32 - HandleSecurity sec;
1.33 -
1.34 - sec.pOwner = NULL;
1.35 - sec.pIdentity = myself->GetIdentity();
1.36 -
1.37 -
1.38 - if ((err=handlesys->ReadHandle(hndl, g_OutputManager.VariantHandle, &sec, (void **)&pInfo))
1.39 - != HandleError_None)
1.40 - {
1.41 - return pContext->ThrowNativeError("Invalid variant handle %x (error %d)", hndl, err);
1.42 - }
1.43 -
1.44 - if (pInfo->crab.FieldType() != FIELD_INTEGER)
1.45 - {
1.46 - return pContext->ThrowNativeError("Variant is not an integer");
1.47 - }
1.48 -
1.49 - return pInfo->crab.Int();
1.50 -}
1.51 -
1.52 -static cell_t GetVariantBool(IPluginContext *pContext, const cell_t *params)
1.53 -{
1.54 - Handle_t hndl = static_cast<Handle_t>(params[1]);
1.55 - HandleError err;
1.56 - varhandle_t *pInfo;
1.57 - HandleSecurity sec;
1.58 -
1.59 - sec.pOwner = NULL;
1.60 - sec.pIdentity = myself->GetIdentity();
1.61 -
1.62 - if ((err=handlesys->ReadHandle(hndl, g_OutputManager.VariantHandle, &sec, (void **)&pInfo))
1.63 - != HandleError_None)
1.64 - {
1.65 - return pContext->ThrowNativeError("Invalid variant handle %x (error %d)", hndl, err);
1.66 - }
1.67 -
1.68 - if (pInfo->crab.FieldType() != FIELD_BOOLEAN)
1.69 - {
1.70 - return pContext->ThrowNativeError("Variant is not a boolean");
1.71 - }
1.72 -
1.73 - return pInfo->crab.Bool();
1.74 -}
1.75 -
1.76 -static cell_t GetVariantEntity(IPluginContext *pContext, const cell_t *params)
1.77 -{
1.78 - Handle_t hndl = static_cast<Handle_t>(params[1]);
1.79 - HandleError err;
1.80 - varhandle_t *pInfo;
1.81 - HandleSecurity sec;
1.82 -
1.83 - sec.pOwner = NULL;
1.84 - sec.pIdentity = myself->GetIdentity();
1.85 -
1.86 - if ((err=handlesys->ReadHandle(hndl, g_OutputManager.VariantHandle, &sec, (void **)&pInfo))
1.87 - != HandleError_None)
1.88 - {
1.89 - return pContext->ThrowNativeError("Invalid variant handle %x (error %d)", hndl, err);
1.90 - }
1.91 -
1.92 - if (pInfo->crab.FieldType() != FIELD_EHANDLE)
1.93 - {
1.94 - return pContext->ThrowNativeError("Variant is not an entity");
1.95 - }
1.96 -
1.97 - edict_t *pEdict = g_OutputManager.BaseHandleToEdict((CBaseHandle)pInfo->crab.Entity());
1.98 -
1.99 - return engine->IndexOfEdict(pEdict);
1.100 -}
1.101 -
1.102 -static cell_t GetVariantFloat(IPluginContext *pContext, const cell_t *params)
1.103 -{
1.104 - Handle_t hndl = static_cast<Handle_t>(params[1]);
1.105 - HandleError err;
1.106 - varhandle_t *pInfo;
1.107 - HandleSecurity sec;
1.108 -
1.109 - sec.pOwner = NULL;
1.110 - sec.pIdentity = myself->GetIdentity();
1.111 -
1.112 - if ((err=handlesys->ReadHandle(hndl, g_OutputManager.VariantHandle, &sec, (void **)&pInfo))
1.113 - != HandleError_None)
1.114 - {
1.115 - return pContext->ThrowNativeError("Invalid variant handle %x (error %d)", hndl, err);
1.116 - }
1.117 -
1.118 - if (pInfo->crab.FieldType() != FIELD_FLOAT)
1.119 - {
1.120 - return pContext->ThrowNativeError("Variant is not a float");
1.121 - }
1.122 -
1.123 - return sp_ftoc(pInfo->crab.Float());
1.124 -}
1.125 -
1.126 -static cell_t GetVariantVector(IPluginContext *pContext, const cell_t *params)
1.127 -{
1.128 - Handle_t hndl = static_cast<Handle_t>(params[1]);
1.129 - HandleError err;
1.130 - varhandle_t *pInfo;
1.131 - HandleSecurity sec;
1.132 -
1.133 - sec.pOwner = NULL;
1.134 - sec.pIdentity = myself->GetIdentity();
1.135 -
1.136 - if ((err=handlesys->ReadHandle(hndl, g_OutputManager.VariantHandle, &sec, (void **)&pInfo))
1.137 - != HandleError_None)
1.138 - {
1.139 - return pContext->ThrowNativeError("Invalid variant handle %x (error %d)", hndl, err);
1.140 - }
1.141 -
1.142 - if (pInfo->crab.FieldType() != FIELD_VECTOR)
1.143 - {
1.144 - return pContext->ThrowNativeError("Variant is not a vector");
1.145 - }
1.146 -
1.147 - cell_t *r;
1.148 - pContext->LocalToPhysAddr(params[2], &r);
1.149 -
1.150 - Vector temp;
1.151 - pInfo->crab.Vector3D(temp);
1.152 -
1.153 - r[0] = sp_ftoc(temp[0]);
1.154 - r[1] = sp_ftoc(temp[1]);
1.155 - r[2] = sp_ftoc(temp[2]);
1.156 -
1.157 - return 0;
1.158 -}
1.159 -
1.160 -static cell_t GetVariantColour(IPluginContext *pContext, const cell_t *params)
1.161 -{
1.162 - Handle_t hndl = static_cast<Handle_t>(params[1]);
1.163 - HandleError err;
1.164 - varhandle_t *pInfo;
1.165 - HandleSecurity sec;
1.166 -
1.167 - sec.pOwner = NULL;
1.168 - sec.pIdentity = myself->GetIdentity();
1.169 -
1.170 - if ((err=handlesys->ReadHandle(hndl, g_OutputManager.VariantHandle, &sec, (void **)&pInfo))
1.171 - != HandleError_None)
1.172 - {
1.173 - return pContext->ThrowNativeError("Invalid variant handle %x (error %d)", hndl, err);
1.174 - }
1.175 -
1.176 - if (pInfo->crab.FieldType() != FIELD_COLOR32)
1.177 - {
1.178 - return pContext->ThrowNativeError("Variant is not a colour");
1.179 - }
1.180 -
1.181 - cell_t *r;
1.182 - pContext->LocalToPhysAddr(params[2], &r);
1.183 -
1.184 - color32 temp = pInfo->crab.Color32();
1.185 -
1.186 - r[0] = temp.r;
1.187 - r[1] = temp.g;
1.188 - r[2] = temp.b;
1.189 - r[4] = temp.a;
1.190 -
1.191 - return 0;
1.192 -}
1.193 -
1.194 -static cell_t GetVariantString(IPluginContext *pContext, const cell_t *params)
1.195 -{
1.196 - Handle_t hndl = static_cast<Handle_t>(params[1]);
1.197 - HandleError err;
1.198 - varhandle_t *pInfo;
1.199 - HandleSecurity sec;
1.200 -
1.201 - sec.pOwner = NULL;
1.202 - sec.pIdentity = myself->GetIdentity();
1.203 -
1.204 - if ((err=handlesys->ReadHandle(hndl, g_OutputManager.VariantHandle, &sec, (void **)&pInfo))
1.205 - != HandleError_None)
1.206 - {
1.207 - return pContext->ThrowNativeError("Invalid variant handle %x (error %d)", hndl, err);
1.208 - }
1.209 -
1.210 - char *dest;
1.211 - const char *src = pInfo->crab.String();
1.212 - size_t len;
1.213 -
1.214 - pContext->LocalToString(params[2], &dest);
1.215 -
1.216 - /* Perform bounds checking */
1.217 - len = strlen(src);
1.218 - if (len >= (unsigned)params[3])
1.219 - {
1.220 - len = params[3] - 1;
1.221 - } else {
1.222 - len = params[3];
1.223 - }
1.224 -
1.225 - /* Copy */
1.226 - memmove(dest, src, len);
1.227 -
1.228 - dest[len] = '\0';
1.229 -
1.230 - return 0;
1.231 -}
1.232 -#endif
1.233 -
1.234 sp_nativeinfo_t g_EntOutputNatives[] =
1.235 {
1.236 {"HookEntityOutput", HookEntityOutput},
1.237 {"UnhookEntityOutput", UnHookEntityOutput},
1.238 {"HookSingleEntityOutput", HookSingleEntityOutput},
1.239 {"UnhookSingleEntityOutput", UnHookSingleEntityOutput},
1.240 -#if 0 //Removed because we don't need them
1.241 - {"GetVariantType", GetVariantType},
1.242 - {"GetVariantInt", GetVariantInt},
1.243 - {"GetVariantFloat", GetVariantFloat},
1.244 - {"GetVariantBool", GetVariantBool},
1.245 - {"GetVariantString", GetVariantString},
1.246 - {"GetVariantEntity", GetVariantEntity},
1.247 - {"GetVariantVector", GetVariantVector},
1.248 - {"GetVariantColour", GetVariantColour},
1.249 -#endif
1.250 {NULL, NULL},
1.251 -};
1.252 -
1.253 -#if 0
1.254 -//Include file stuff that wasn't needed:
1.255 -
1.256 -enum FieldType
1.257 -{
1.258 - FieldType_Float = 1,
1.259 - FieldType_String = 2,
1.260 - FieldType_Vector = 3,
1.261 - FieldType_Int = 5,
1.262 - FieldType_Bool = 6,
1.263 - FieldType_Colour = 9,
1.264 - FieldType_Entity = 13
1.265 -}
1.266 -
1.267 -/**
1.268 - * Gets the current type of a variant handle
1.269 - *
1.270 - * @param variant A variant handle.
1.271 - * @return Current type of the variant.
1.272 - */
1.273 -native FieldType:GetVariantType(Handle:variant);
1.274 -
1.275 -/**
1.276 - * Retreives a Float from a variant handle.
1.277 - *
1.278 - * @param variant A variant handle.
1.279 - * @return Float value.
1.280 - * @error Variant handle is not type FieldType_Float
1.281 - */
1.282 -native Float:GetVariantFloat(Handle:variant);
1.283 -
1.284 -/**
1.285 - * Retreives an Integer from a variant handle.
1.286 - *
1.287 - * @param variant A variant handle.
1.288 - * @return Int value.
1.289 - * @error Variant handle is not type FieldType_Int
1.290 - */
1.291 -native GetVariantInt(Handle:variant);
1.292 -
1.293 -/**
1.294 - * Retreives a bool from a variant handle.
1.295 - *
1.296 - * @param variant A variant handle.
1.297 - * @return bool value.
1.298 - * @error Variant handle is not type FieldType_Bool
1.299 - */
1.300 -native bool:GetVariantBool(Handle:variant);
1.301 -
1.302 -/**
1.303 - * Retreives an entity from a variant handle.
1.304 - *
1.305 - * @param variant A variant handle.
1.306 - * @return Entity Index.
1.307 - * @error Variant handle is not type FieldType_Entity
1.308 - */
1.309 -native GetVariantEntity(Handle:variant);
1.310 -
1.311 -/**
1.312 - * Retreives a Vector from a variant handle.
1.313 - *
1.314 - * @param variant A variant handle.
1.315 - * @param vec buffer to store the Vector.
1.316 - * @noreturn
1.317 - * @error Variant handle is not type FieldType_Vector
1.318 - */
1.319 -native GetVariantVector(Handle:variant, Float:vec[3]);
1.320 -
1.321 -/**
1.322 - * Retreives a String from a variant handle.
1.323 - *
1.324 - * @note This native does not require the variant to be FieldType_String,
1.325 - * It can convert any type into a string representation.
1.326 - *
1.327 - * @param variant A variant handle.
1.328 - * @param buffer buffer to store the string in
1.329 - * @param maxlen Maximum length of buffer.
1.330 - * @noreturn
1.331 - */
1.332 -native GetVariantString(Handle:variant, String:buffer[], maxlen);
1.333 -
1.334 -/**
1.335 - * Retreives a Colour from a variant handle.
1.336 - *
1.337 - * @note Colour is in format r,g,b,a
1.338 - *
1.339 - * @param variant A variant handle.
1.340 - * @param colour buffer array to store the colour in.
1.341 - * @noreturn
1.342 - * @error Variant handle is not type FieldType_Colour
1.343 - */
1.344 -native GetVariantColour(Handle:variant, colour[4]);
1.345 -#endif
1.346 +};
1.347 \ No newline at end of file