1.1 --- a/plugins/include/entity.inc Fri Mar 02 01:56:56 2007 +0000
1.2 +++ b/plugins/include/entity.inc Fri Mar 02 08:00:45 2007 +0000
1.3 @@ -129,3 +129,123 @@
1.4 * @error Invalid edict index.
1.5 */
1.6 native bool:GetEntityNetClass(edict, String:clsname[], maxlength);
1.7 +
1.8 +/**
1.9 + * @section Entity offset functions
1.10 + *
1.11 + * Offsets should be specified in byte distance from the CBaseEntity
1.12 + * structure, not short (double byte) or integer (four byte) multiples.
1.13 + * It is somewhat common practice to use offsets aligned to their final
1.14 + * type, and thus make sure you are not falling to this error in SourceMod.
1.15 + * For example, if your "integer-aligned" offset was 119, your byte-aligned
1.16 + * offset is 119*4, or 476.
1.17 +
1.18 + * Specifying incorrect offsets or the incorrect data type for an offset
1.19 + * can have fatal consequences. If you are hardcoding offsets, and the
1.20 + * layout of CBaseEntity does not match, you can easily crash the server.
1.21 + *
1.22 + * The reasonable bounds for offsets is greater than or equal to 0 and
1.23 + * below 32768. Offsets out of these bounds will throw an error. However,
1.24 + * this does not represent any real range, it is simply a sanity check for
1.25 + * illegal values. Any range outside of the CBaseEntity structure's private
1.26 + * size will cause undefined behaviour or even crash.
1.27 + */
1.28 +
1.29 +/**
1.30 + * Peeks into an entity's object data and retrieves the integer value at
1.31 + * the given offset.
1.32 + *
1.33 + * @param entity Edict index.
1.34 + * @param offset Offset to use.
1.35 + * @param size Number of bytes to read (valid values are 1, 2, or 4).
1.36 + * @return Value at the given memory location.
1.37 + * @error Invalid entity or offset out of reasonable bounds.
1.38 + */
1.39 +native GetEntData(entity, offset, size=4);
1.40 +
1.41 +/**
1.42 + * Peeks into an entity's object data and sets the integer value at
1.43 + * the given offset.
1.44 + *
1.45 + * @param entity Edict index.
1.46 + * @param offset Offset to use.
1.47 + * @param size Number of bytes to write (valid values are 1, 2, or 4).
1.48 + * @return Value at the given memory location.
1.49 + * @error Invalid entity or offset out of reasonable bounds.
1.50 + * @noreturn
1.51 + */
1.52 +native SetEntData(entity, offset, value, size=4);
1.53 +
1.54 +/**
1.55 + * Peeks into an entity's object data and retrieves the float value at
1.56 + * the given offset.
1.57 + *
1.58 + * @param entity Edict index.
1.59 + * @param offset Offset to use.
1.60 + * @return Value at the given memory location.
1.61 + * @error Invalid entity or offset out of reasonable bounds.
1.62 + */
1.63 +native Float:GetEntDataFloat(entity, offset);
1.64 +
1.65 +/**
1.66 + * Peeks into an entity's object data and sets the integer value at
1.67 + * the given offset.
1.68 + *
1.69 + * @param entity Edict index.
1.70 + * @param offset Offset to use.
1.71 + * @return Value at the given memory location.
1.72 + * @error Invalid entity or offset out of reasonable bounds.
1.73 + * @noreturn
1.74 + */
1.75 +native SetEntDataFloat(entity, offset, Float:value);
1.76 +
1.77 +/**
1.78 + * Peeks into an entity's object data and retrieves the entity handle
1.79 + * info at the given offset.
1.80 + *
1.81 + * @param entity Edict index.
1.82 + * @param offset Offset to use.
1.83 + * @return Entity index at the given location, or 0 if none.
1.84 + * @error Invalid entity or offset out of reasonable bounds.
1.85 + */
1.86 +native GetEntDataEnt(entity, offset);
1.87 +
1.88 +/**
1.89 + * Peeks into an entity's object data and sest the entity handle info
1.90 + * at the given offset.
1.91 + *
1.92 + * @param entity Edict index.
1.93 + * @param offset Offset to use.
1.94 + * @param other Entity index to set, or 0 to clear.
1.95 + * @noreturn
1.96 + * @error Invalid entity or offset out of reasonable bounds.
1.97 + */
1.98 +native SetEntDataEnt(entity, offset, other);
1.99 +
1.100 +/**
1.101 + * Peeks into an entity's object data and retrieves the vector at the
1.102 + * given offset.
1.103 + * @note Both a Vector and a QAngle are three floats. This is a
1.104 + * convenience function and will work with both types.
1.105 + *
1.106 + * @param entity Edict index.
1.107 + * @param offset Offset to use.
1.108 + * @param vec Vector buffer to store data in.
1.109 + * @noreturn
1.110 + * @error Invalid entity or offset out of reasonable bounds.
1.111 + */
1.112 +native GetEntDataVector(entity, offset, Float:vec[3]);
1.113 +
1.114 +/**
1.115 + * Peeks into an entity's object data and sets the vector at the given
1.116 + * offset.
1.117 + * @note Both a Vector and a QAngle are three floats. This is a
1.118 + * convenience function and will work with both types.
1.119 + *
1.120 + * @param entity Edict index.
1.121 + * @param offset Offset to use.
1.122 + * @param vec Vector to set.
1.123 + * @noreturn
1.124 + * @error Invalid entity or offset out of reasonable bounds.
1.125 + */
1.126 +native SetEntDataVector(entity, offset, const Float:vec[3]);