Remove XS__LIBRELEASE and tabs so docgen can catch the stocks

This commit is contained in:
xPaw 2014-08-03 22:26:54 +03:00
parent 69371d6d6d
commit c219878ac2

View File

@ -101,20 +101,6 @@
#define XS_REPLACEBUF_SIZE 3072
#endif
// Turn on for release
#define XS__LIBRELEASE 1
#if XS__LIBRELEASE
#define XS_LIBFUNC_ATTRIB stock
#else
#define XS_LIBFUNC_ATTRIB
#endif
#if XS__LIBRELEASE
#define XS_LIBVAR_ATTRIB stock
#else
#define XS_LIBVAR_ATTRIB new
#endif
/****** DEBUGGING / LOGING FUNCTIONS ******/
enum xs_logtypes
@ -130,10 +116,10 @@
xs_logtypes_count
}
XS_LIBVAR_ATTRIB const xs__logtypenames[xs_logtypes_count][] = {"DEBUG", "", "WARNING", "ERROR", "FATAL ERROR", "DEBUG ASSERTION FAILED"};
stock const xs__logtypenames[xs_logtypes_count][] = {"DEBUG", "", "WARNING", "ERROR", "FATAL ERROR", "DEBUG ASSERTION FAILED"};
// tested
XS_LIBFUNC_ATTRIB xs_log(xs_logtypes:logtype, {Float,_}:...)
stock xs_log(xs_logtypes:logtype, {Float,_}:...)
{
// WARNING: Don't try to use assert in here; it uses this func
@ -155,7 +141,7 @@
// Assertion
// tested
XS_LIBFUNC_ATTRIB xs_assertfunc({Float,_}:exp, const desc[])
stock xs_assertfunc({Float,_}:exp, const desc[])
{
// Check exp
if (exp)
@ -187,53 +173,53 @@
// Returns -1 if num is negative, 0 if num is 0, 1 if num is positive
// tested
XS_LIBFUNC_ATTRIB xs_sign(num)
stock xs_sign(num)
{
return (num < 0) ? -1 : ((num == 0) ? 0 : 1);
}
// Returns -1 if num is negative, 0 if num is 0, 1 if num is positive
// tested
XS_LIBFUNC_ATTRIB xs_fsign(Float:num)
stock xs_fsign(Float:num)
{
return (num < 0.0) ? -1 : ((num == 0.0) ? 0 : 1);
}
// Returns absolute value
// tested
XS_LIBFUNC_ATTRIB xs_abs(num)
stock xs_abs(num)
{
return (num < 0) ? -num : num;
}
// is power of 2? (== can be expressed as 1<<i)
// tested
XS_LIBFUNC_ATTRIB xs_is_2power(x)
stock xs_is_2power(x)
{
return (x!=0) && ((x&(x-1))==0);
}
// degrees to radians
// tested
XS_LIBFUNC_ATTRIB Float:xs_deg2rad(Float:x)
stock Float:xs_deg2rad(Float:x)
{
return x * 0.017453292519943;
}
// tested
XS_LIBFUNC_ATTRIB Float:xs_rad2deg(Float:x)
stock Float:xs_rad2deg(Float:x)
{
return x * 57.29577951308232;
}
// untested, should work though
XS_LIBFUNC_ATTRIB Float:xs_gra2rad(Float:x)
stock Float:xs_gra2rad(Float:x)
{
return x * 0.015707963267948;
}
// untested, should work though
XS_LIBFUNC_ATTRIB Float:xs_rad2gra(Float:x)
stock Float:xs_rad2gra(Float:x)
{
return x * 63.66197723675813;
}
@ -244,14 +230,14 @@
// 1/sqrt
// tested
XS_LIBFUNC_ATTRIB Float:xs_rsqrt(Float:x)
stock Float:xs_rsqrt(Float:x)
{
return 1.0 / floatsqroot(x);
}
// sqrt
// tested
XS_LIBFUNC_ATTRIB Float:xs_sqrt(Float:x)
stock Float:xs_sqrt(Float:x)
{
return floatsqroot(x);
}
@ -327,18 +313,18 @@
// (ISBN 0-201-47960-5). This is a "multiplicative congruential random number
// generator" that has been extended to 31-bits
XS_LIBVAR_ATTRIB xs__internalseed=0x546875;
stock xs__internalseed=0x546875;
#define XS__IL_RMULT 1103515245
// tested
XS_LIBFUNC_ATTRIB xs_seed(seed)
stock xs_seed(seed)
{
xs__internalseed = seed;
}
// tested
XS_LIBFUNC_ATTRIB xs_irand()
stock xs_irand()
{
new lo, hi, ll, lh, hh, hl;
new result;
@ -355,13 +341,13 @@
}
// tested
XS_LIBFUNC_ATTRIB Float:xs_frand()
stock Float:xs_frand()
{
return float(xs_irand()) / float(xs_get_maxnum()); // -1/2 should be the biggest possible positive number
}
// tested
XS_LIBFUNC_ATTRIB xs_irand_range(pmin, pmax)
stock xs_irand_range(pmin, pmax)
{
xs_assert_dbg(pmax - pmin >= 0, "xs_irand_range: pmin > pmax");
new i = pmin + floatround(xs_frand() * float(pmax - pmin));
@ -376,7 +362,7 @@
// Set vec components to values
// tested
XS_LIBFUNC_ATTRIB xs_vec_set(Float:vec[], Float:x, Float:y, Float:z)
stock xs_vec_set(Float:vec[], Float:x, Float:y, Float:z)
{
vec[0] = x;
vec[1] = y;
@ -385,7 +371,7 @@
// Add vec
// tested
XS_LIBFUNC_ATTRIB xs_vec_add(const Float:in1[], const Float:in2[], Float:out[])
stock xs_vec_add(const Float:in1[], const Float:in2[], Float:out[])
{
out[0] = in1[0] + in2[0];
out[1] = in1[1] + in2[1];
@ -394,7 +380,7 @@
// Subtract vec
// untested, but should work
XS_LIBFUNC_ATTRIB xs_vec_sub(const Float:in1[], const Float:in2[], Float:out[])
stock xs_vec_sub(const Float:in1[], const Float:in2[], Float:out[])
{
out[0] = in1[0] - in2[0];
out[1] = in1[1] - in2[1];
@ -403,21 +389,21 @@
// Are vectors equal?
// untested, but should work
XS_LIBFUNC_ATTRIB bool:xs_vec_equal(const Float:vec1[], const Float:vec2[])
stock bool:xs_vec_equal(const Float:vec1[], const Float:vec2[])
{
return (vec1[0] == vec2[0]) && (vec1[1] == vec2[1]) && (vec1[2] == vec2[2]);
}
// Are vectors nearly equal?
// tested
XS_LIBFUNC_ATTRIB bool:xs_vec_nearlyequal(const Float:vec1[], const Float:vec2[])
stock bool:xs_vec_nearlyequal(const Float:vec1[], const Float:vec2[])
{
return XS_FLEQ(vec1[0], vec2[0]) && XS_FLEQ(vec1[1], vec2[1]) && XS_FLEQ(vec1[2], vec2[2]);
}
// multiply vector by scalar
// tested
XS_LIBFUNC_ATTRIB xs_vec_mul_scalar(const Float:vec[], Float:scalar, Float:out[])
stock xs_vec_mul_scalar(const Float:vec[], Float:scalar, Float:out[])
{
out[0] = vec[0] * scalar;
out[1] = vec[1] * scalar;
@ -426,7 +412,7 @@
// divide vector by scalar
// untested, but should work
XS_LIBFUNC_ATTRIB xs_vec_div_scalar(const Float:vec[], Float:scalar, Float:out[])
stock xs_vec_div_scalar(const Float:vec[], Float:scalar, Float:out[])
{
new Float:__tmp = 1.0 / scalar;
out[0] = vec[0] * __tmp;
@ -436,14 +422,14 @@
// Compute vector length
// tested
XS_LIBFUNC_ATTRIB Float:xs_vec_len(const Float:vec[])
stock Float:xs_vec_len(const Float:vec[])
{
return xs_sqrt(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2]);
}
// Normalize vec
// tested
XS_LIBFUNC_ATTRIB xs_vec_normalize(const Float:vec[], Float:out[])
stock xs_vec_normalize(const Float:vec[], Float:out[])
{
new Float:invlen = xs_rsqrt(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2]);
out[0] = vec[0] * invlen;
@ -453,7 +439,7 @@
// Store the cross product of vec1 and vec2 in out
// tested
XS_LIBFUNC_ATTRIB xs_vec_cross(const Float:vec1[], const Float:vec2[], Float:out[])
stock xs_vec_cross(const Float:vec1[], const Float:vec2[], Float:out[])
{
out[0] = vec1[1]*vec2[2] - vec1[2]*vec2[1];
out[1] = vec1[2]*vec2[0] - vec1[0]*vec2[2];
@ -462,14 +448,14 @@
// Compute vec1 dot vec2
// tested
XS_LIBFUNC_ATTRIB Float:xs_vec_dot(const Float:vec1[], const Float:vec2[])
stock Float:xs_vec_dot(const Float:vec1[], const Float:vec2[])
{
return vec1[0]*vec2[0] + vec1[1]*vec2[1] + vec1[2]*vec2[2];
}
// Negate vec into out
// untested, but should work
XS_LIBFUNC_ATTRIB xs_vec_neg(const Float:vec[], Float:out[])
stock xs_vec_neg(const Float:vec[], Float:out[])
{
out[0] = -vec[0];
out[1] = -vec[1];
@ -478,7 +464,7 @@
// Copy vec
// untested, but should work
XS_LIBFUNC_ATTRIB xs_vec_copy(const Float:vecIn[], Float:vecOut[])
stock xs_vec_copy(const Float:vecIn[], Float:vecOut[])
{
vecOut[0] = vecIn[0];
vecOut[1] = vecIn[1];
@ -487,14 +473,14 @@
// Compute angle between vec1 and vec2
// tested
XS_LIBFUNC_ATTRIB Float:xs_vec_angle(const Float:vec1[], const Float:vec2[])
stock Float:xs_vec_angle(const Float:vec1[], const Float:vec2[])
{
return xs_rad2deg(xs_acos(xs_vec_dot(vec1, vec2), radian));
}
// Reflect vec about normal
// untested
XS_LIBFUNC_ATTRIB xs_vec_reflect(const Float:vec[], const Float:normal[], Float:out[])
stock xs_vec_reflect(const Float:vec[], const Float:normal[], Float:out[])
{
// normalize(vec) - (normal * 2.0 * (tmp . normal)) * length(vec)
@ -515,7 +501,7 @@
}
// Turn a 3D vector into a 2D vector
XS_LIBFUNC_ATTRIB xs_vec_make2d(const Float:vec[3], Float:out[2])
stock xs_vec_make2d(const Float:vec[3], Float:out[2])
{
out[0] = vec[0];
out[1] = vec[1];
@ -533,7 +519,7 @@
// Set a plane to specific values
// tested
XS_LIBFUNC_ATTRIB xs_plane_set(Float:plane[], Float:a, Float:b, Float:c, Float:d)
stock xs_plane_set(Float:plane[], Float:a, Float:b, Float:c, Float:d)
{
plane[XS_PLANE_A] = a;
plane[XS_PLANE_B] = b;
@ -543,7 +529,7 @@
// Construct a plane out of 3 points
// tested
XS_LIBFUNC_ATTRIB xs_plane_3p(Float:plane[], const Float:p1[], const Float:p2[], const Float:p3[])
stock xs_plane_3p(Float:plane[], const Float:p1[], const Float:p2[], const Float:p3[])
{
new Float:normalA[3], Float:normalB[3];
@ -571,7 +557,7 @@
}
// untested, but should work
XS_LIBFUNC_ATTRIB bool:xs_plane_equal(const Float:plane1[], const Float:plane2[])
stock bool:xs_plane_equal(const Float:plane1[], const Float:plane2[])
{
if ( (plane1[0] == plane2[0]) &&
(plane1[1] == plane2[1]) &&
@ -582,7 +568,7 @@
}
// untested, but should work
XS_LIBFUNC_ATTRIB bool:xs_plane_nearlyequal(const Float:plane1[], const Float:plane2[])
stock bool:xs_plane_nearlyequal(const Float:plane1[], const Float:plane2[])
{
if ( XS_FLEQ(plane1[0], plane2[0]) &&
XS_FLEQ(plane1[1], plane2[1]) &&
@ -594,7 +580,7 @@
// Compute distance between plane and point
// tested
XS_LIBFUNC_ATTRIB Float:xs_plane_dst2point(const Float:plane[], const Float:point[])
stock Float:xs_plane_dst2point(const Float:plane[], const Float:point[])
{
// return normal dot point + D
return xs_vec_dot(plane, point) + plane[XS_PLANE_D];
@ -604,7 +590,7 @@
// If yes, returns true and sets out to the intersection point
// Otherwise, returns false
// tested
XS_LIBFUNC_ATTRIB bool:xs_plane_rayintersect(const Float:plane[], const Float:rayStart[], const Float:rayDir[], Float:out[])
stock bool:xs_plane_rayintersect(const Float:plane[], const Float:rayStart[], const Float:rayDir[], Float:out[])
{
new Float:a = xs_vec_dot(plane, rayDir);
@ -632,14 +618,14 @@
// Is point on plane?
// tested
XS_LIBFUNC_ATTRIB bool:xs_point_onplane(const Float:plane[], const Float:point[])
stock bool:xs_point_onplane(const Float:plane[], const Float:point[])
{
return XS_FLEQ(xs_plane_dst2point(plane, point), 0.0);
}
// Project point on plane
// tested
XS_LIBFUNC_ATTRIB xs_projpoint_onplane(const Float:plane[], const Float:point[], Float:out[])
stock xs_projpoint_onplane(const Float:plane[], const Float:point[], Float:out[])
{
new Float:__tmp[3];
// out = point - (plane normal * distance point<->plane)
@ -650,7 +636,7 @@
// Copy plane
// untested, but should work
XS_LIBFUNC_ATTRIB xs_plane_copy(const Float:planeIn[], Float:planeOut[])
stock xs_plane_copy(const Float:planeIn[], Float:planeOut[])
{
planeOut[0] = planeIn[0];
planeOut[1] = planeIn[1];
@ -667,7 +653,7 @@
#define XS_YAW 1 // left / right
#define XS_ROLL 2 // fall over
XS_LIBFUNC_ATTRIB xs_anglevectors(const Float:angles[3], Float:fwd[3], Float:right[3], Float:up[3])
stock xs_anglevectors(const Float:angles[3], Float:fwd[3], Float:right[3], Float:up[3])
{
// sin (s) and cos (c) for yaw (y), pitch (p) and roll (r)
new Float:sr, Float:sp, Float:sy, Float:cr, Float:cp, Float:cy;
@ -694,7 +680,7 @@
/****** STRING FUNCS *******/
// tested
XS_LIBFUNC_ATTRIB xs_strchr(const str[], chr)
stock xs_strchr(const str[], chr)
{
for (new i = 0; str[i] != 0; ++i)
{
@ -709,7 +695,7 @@
// - beginning if fromleft is true
// - end if fromleft is false
// tested
XS_LIBFUNC_ATTRIB xs_strtrim(stringtotrim[], charstotrim, bool:fromleft = true)
stock xs_strtrim(stringtotrim[], charstotrim, bool:fromleft = true)
{
if (charstotrim <= 0)
return;
@ -740,7 +726,7 @@
// if outlen is positive, it specifies the maximal number of characters to be copied.
// otherwise, assumes that newmsg is at least end-start+1 characters long.
// tested
XS_LIBFUNC_ATTRIB xs_strmid(const oldmsg[], newmsg[], start, end, outlen=-1)
stock xs_strmid(const oldmsg[], newmsg[], start, end, outlen=-1)
{
new len = strlen(oldmsg);
@ -762,7 +748,7 @@
// by xeroblood, adapted
// maxelems: maximal number of elements in output, elemsize: maximal size of one element
// tested
XS_LIBFUNC_ATTRIB xs_explode(const input[], output[][], delimiter, maxelems, elemsize)
stock xs_explode(const input[], output[][], delimiter, maxelems, elemsize)
{
new nIdx = 0;
new nLen = 0;
@ -790,7 +776,7 @@
}
// returns number of cells written.
XS_LIBFUNC_ATTRIB xs_implode(output[], outsize, delimiter, const input[][], elemsnum)
stock xs_implode(output[], outsize, delimiter, const input[][], elemsnum)
{
new pos = 0;
new copied;
@ -813,10 +799,10 @@
}
XS_LIBVAR_ATTRIB xs__replace_buf[XS_REPLACEBUF_SIZE];
stock xs__replace_buf[XS_REPLACEBUF_SIZE];
// Replace all occurencies of what in text with with
// Returns number of (also partially if trimmed by len) replaced items.
XS_LIBFUNC_ATTRIB xs_replace(text[], len, const what[], const with[])
stock xs_replace(text[], len, const what[], const with[])
{
new occur = 0;
new i = 0;
@ -856,7 +842,7 @@
// replaces all occurencies of what in text with with
// Returns number of replaced items.
XS_LIBFUNC_ATTRIB xs_replace_char(text[], len, what, with)
stock xs_replace_char(text[], len, what, with)
{
// let the xs_replace function do the work
new arr[4];
@ -871,7 +857,7 @@
/****** MISC FUNCS *******/
// sets namestr to name of the command identified by cid
// half-tested
XS_LIBFUNC_ATTRIB xs_concmd_name(cid, namestr[], namelen)
stock xs_concmd_name(cid, namestr[], namelen)
{
new dummy1;
new dummy2[1];
@ -880,7 +866,7 @@
// Checks whether there are at least num free visible slots
// half-tested
XS_LIBFUNC_ATTRIB bool:xs_freevisibleslots(num)
stock bool:xs_freevisibleslots(num)
{
new maxplayers = get_cvar_num("sv_visiblemaxplayers");
if (maxplayers <= 0)
@ -890,9 +876,9 @@
}
// Returns biggest possible positive number
XS_LIBVAR_ATTRIB xs__maxnum = 0;
stock xs__maxnum = 0;
// tested
XS_LIBFUNC_ATTRIB xs_get_maxnum()
stock xs_get_maxnum()
{
if (!xs__maxnum)
{
@ -908,7 +894,7 @@
}
// tested
XS_LIBFUNC_ATTRIB xs_get_minnum()
stock xs_get_minnum()
{
return xs_get_maxnum() + 1;
}
@ -922,7 +908,7 @@
#define XS__MAX_POSSIBLE_MESSAGES 255
// Returns max number of messages for mod
XS_LIBFUNC_ATTRIB xs_get_maxmessages()
stock xs_get_maxmessages()
{
new name[2];
@ -934,7 +920,7 @@
}
// Returns true if msgid is a valid message
XS_LIBFUNC_ATTRIB bool:xs_is_msg_valid(msgid)
stock bool:xs_is_msg_valid(msgid)
{
new name[2];
new retval = get_user_msgname(msgid, name, 1);
@ -948,7 +934,7 @@
/****** MANAGED TASKS ******/
// ***** managed task ids
XS_LIBFUNC_ATTRIB xs_find_freetaskid()
stock xs_find_freetaskid()
{
for (new i = 1; i <= XS_TASK_MANAGEDIDS; ++i)
{
@ -968,15 +954,15 @@
}
// new task
XS_LIBVAR_ATTRIB xs__TaskParam[ 1 + // number of parameters
stock xs__TaskParam[ 1 + // number of parameters
XS_TASK_MAXPARAMS + // parameter types
(XS_TASK_MAXPARAMSIZE char) * XS_TASK_MAXPARAMS]; // space for len + value
XS_LIBVAR_ATTRIB Float:xs__TaskInterval = 0.0;
XS_LIBVAR_ATTRIB xs__TaskFlags[5];
XS_LIBVAR_ATTRIB xs__TaskFunc[48];
XS_LIBVAR_ATTRIB xs__TaskId;
XS_LIBVAR_ATTRIB xs__TaskRepeat;
stock Float:xs__TaskInterval = 0.0;
stock xs__TaskFlags[5];
stock xs__TaskFunc[48];
stock xs__TaskId;
stock xs__TaskRepeat;
#define xs__TaskParamCount xs__TaskParam[0]
#define xs__TaskParamType[%1] xs__TaskParam[1 + %1]
@ -985,10 +971,10 @@
// incoming task
XS_LIBVAR_ATTRIB xs__ITaskParam[ 1 + // number of parameters
stock xs__ITaskParam[ 1 + // number of parameters
XS_TASK_MAXPARAMS + // parameter types
(XS_TASK_MAXPARAMSIZE char) * XS_TASK_MAXPARAMS]; // space for len + value
XS_LIBVAR_ATTRIB xs__ITaskId;
stock xs__ITaskId;
#define xs__ITaskParamCount xs__ITaskParam[0]
#define xs__ITaskParamType[%1] xs__ITaskParam[1 + %1]
@ -996,7 +982,7 @@
#define xs__ITaskParamValue[%1] xs__ITaskParam[1 + XS_TASK_MAXPARAMS + (%1 * (XS_TASK_MAXPARAMSIZE char))]
// tested
XS_LIBFUNC_ATTRIB xs_task_begin(Float:interval, const func[], id = 0, const flags[] = "", repeat = 0)
stock xs_task_begin(Float:interval, const func[], id = 0, const flags[] = "", repeat = 0)
{
xs_assert(xs__TaskInterval == 0.0, "New xs_task_begin called before xs_task_end");
@ -1013,7 +999,7 @@
}
// tested
XS_LIBFUNC_ATTRIB xs_task_pushint(value, bool:__isfl=false /*internal use only*/)
stock xs_task_pushint(value, bool:__isfl=false /*internal use only*/)
{
xs_assert(xs__TaskInterval, "xs_task_push* called without xs_task_begin");
if (xs__TaskParamCount >= XS_TASK_MAXPARAMS)
@ -1027,13 +1013,13 @@
}
// tested
XS_LIBFUNC_ATTRIB xs_task_pushfl(Float:value)
stock xs_task_pushfl(Float:value)
{
return xs_task_pushint(_:value, true);
}
// tested
XS_LIBFUNC_ATTRIB xs_task_pushstr(const value[])
stock xs_task_pushstr(const value[])
{
xs_assert(xs__TaskInterval, "xs_task_push* called without xs_task_begin");
if (xs__TaskParamCount >= XS_TASK_MAXPARAMS)
@ -1046,7 +1032,7 @@
}
// tested
XS_LIBFUNC_ATTRIB xs_task_end()
stock xs_task_end()
{
xs_assert(xs__TaskInterval, "xs_task_end called without xs_task_begin");
@ -1075,7 +1061,7 @@
#define XS_MAKE_TASKFUNC(%1) public %1(const _xs__taskparam[], _xs__taskid) if(xs__task_setup(_xs__taskparam, _xs__taskid))
// tested
XS_LIBFUNC_ATTRIB xs__task_setup(const param[], taskid)
stock xs__task_setup(const param[], taskid)
{
xs__ITaskId = taskid;
new len = 1 + param[0] * (XS_TASK_MAXPARAMSIZE char);
@ -1085,19 +1071,19 @@
}
// tested
XS_LIBFUNC_ATTRIB xs_task_readid()
stock xs_task_readid()
{
return xs__ITaskId;
}
// tested
XS_LIBFUNC_ATTRIB xs_task_paramcount()
stock xs_task_paramcount()
{
return xs__ITaskParamCount;
}
// tested
XS_LIBFUNC_ATTRIB xs_paramtypes:xs_task_paramtype(paramid)
stock xs_paramtypes:xs_task_paramtype(paramid)
{
if (paramid < 0 || paramid >= xs__ITaskParamCount)
return xs_invalid;
@ -1106,7 +1092,7 @@
}
// tested
XS_LIBFUNC_ATTRIB xs_task_paramint(paramid)
stock xs_task_paramint(paramid)
{
if (paramid < 0 || paramid >= xs__ITaskParamCount)
return 0;
@ -1117,7 +1103,7 @@
}
// tested
XS_LIBFUNC_ATTRIB Float:xs_task_paramfl(paramid)
stock Float:xs_task_paramfl(paramid)
{
if (paramid < 0 || paramid >= xs__ITaskParamCount)
return 0.0;
@ -1128,7 +1114,7 @@
}
// tested
XS_LIBFUNC_ATTRIB xs_task_paramstr(paramid, out[], maxlen)
stock xs_task_paramstr(paramid, out[], maxlen)
{
#pragma unused maxlen
@ -1140,4 +1126,3 @@
strunpack(out, xs__ITaskParamValue[paramid]);
return 1;
}