2016-06-21 08:02:44 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
#include "Base/Algo.hpp"
|
|
|
|
|
2016-06-21 14:17:08 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
#include "Entity/Blip.hpp"
|
|
|
|
#include "Entity/Checkpoint.hpp"
|
|
|
|
#include "Entity/Keybind.hpp"
|
|
|
|
#include "Entity/Object.hpp"
|
|
|
|
#include "Entity/Pickup.hpp"
|
|
|
|
#include "Entity/Player.hpp"
|
|
|
|
#include "Entity/Vehicle.hpp"
|
|
|
|
|
2016-06-21 16:25:43 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
#define SQMOD_VALID_NAME_STR(t) if (!t) { STHROWF("The specified name is invalid"); }
|
|
|
|
|
2016-06-21 08:02:44 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
2016-06-21 14:17:08 +02:00
|
|
|
namespace Algo {
|
|
|
|
|
2016-06-21 16:25:43 +02:00
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Used to fake a string so a raw buffer can be used with search algorithms.
|
|
|
|
*/
|
2016-07-14 22:34:52 +02:00
|
|
|
struct FakeString
|
2016-06-21 16:25:43 +02:00
|
|
|
{
|
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
SQChar mBuffer[SQMOD_PLAYER_TMP_BUFFER]; // Buffer to hold the data.
|
|
|
|
std::size_t mSize; // The size of the data in the buffer.
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Default constructor.
|
|
|
|
*/
|
|
|
|
FakeString()
|
|
|
|
: mBuffer(), mSize(0)
|
|
|
|
{
|
|
|
|
/* ... */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Grab the player name from the server into the buffer.
|
|
|
|
*/
|
|
|
|
void GrabName(int id)
|
|
|
|
{
|
|
|
|
// Clear any previous string (just in case)
|
|
|
|
mBuffer[0] = '\0';
|
|
|
|
mSize = 0;
|
|
|
|
// Query the server for the name of the managed player
|
|
|
|
if (_Func->GetPlayerName(id, mBuffer, sizeof(mBuffer)) == vcmpErrorNone)
|
|
|
|
{
|
|
|
|
mSize = std::strlen(mBuffer); // Calculate the name length
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the size of the name.
|
|
|
|
*/
|
|
|
|
std::size_t size() const
|
|
|
|
{
|
|
|
|
return mSize;
|
|
|
|
}
|
|
|
|
|
2016-07-14 22:34:52 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the string buffer.
|
|
|
|
*/
|
|
|
|
CSStr c_str() const
|
|
|
|
{
|
|
|
|
return mBuffer;
|
|
|
|
}
|
|
|
|
|
2016-06-21 16:25:43 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Find in buffer contents of another string.
|
|
|
|
*/
|
|
|
|
std::size_t find(CSStr s) const
|
|
|
|
{
|
|
|
|
CCStr r = std::strstr(mBuffer, s);
|
2016-07-14 22:34:52 +02:00
|
|
|
return (r == nullptr) ? String::npos : (r - mBuffer);
|
2016-06-21 16:25:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Compare the buffer contents with another string.
|
|
|
|
*/
|
|
|
|
int compare(CSStr s) const
|
|
|
|
{
|
|
|
|
return std::strcmp(mBuffer, s);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Compare the buffer contents with another string.
|
|
|
|
*/
|
|
|
|
int compare(std::size_t pos, std::size_t len, CSStr s) const
|
|
|
|
{
|
|
|
|
return std::strncmp(mBuffer + pos, s, len);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Functor to retrieve the player name.
|
|
|
|
*/
|
|
|
|
struct PlayerName
|
|
|
|
{
|
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
FakeString mStr; // The string where the name is stored.
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Function call operator.
|
|
|
|
*/
|
|
|
|
const FakeString & operator () (const typename InstSpec< CPlayer >::Instance & inst)
|
|
|
|
{
|
|
|
|
mStr.GrabName(inst.mID);
|
|
|
|
return mStr;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-06-21 15:15:25 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-02-21 20:24:59 +01:00
|
|
|
static const LightObj & Blip_FindBySprID(Int32 sprid)
|
2016-06-21 15:15:25 +02:00
|
|
|
{
|
|
|
|
// Perform a range check on the specified identifier
|
|
|
|
if (sprid < 0)
|
|
|
|
{
|
|
|
|
STHROWF("The specified sprite identifier is invalid: %d", sprid);
|
|
|
|
}
|
|
|
|
// Obtain the ends of the entity pool
|
|
|
|
Core::Blips::const_iterator itr = Core::Get().GetBlips().cbegin();
|
|
|
|
Core::Blips::const_iterator end = Core::Get().GetBlips().cend();
|
|
|
|
// Process each entity in the pool
|
|
|
|
for (; itr != end; ++itr)
|
|
|
|
{
|
|
|
|
// Does the identifier match the specified one?
|
|
|
|
if (itr->mSprID == sprid)
|
|
|
|
{
|
|
|
|
return itr->mObj; // Stop searching and return this entity
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Unable to locate a blip matching the specified identifier
|
2017-02-21 20:24:59 +01:00
|
|
|
return NullLightObj();
|
2016-06-21 15:15:25 +02:00
|
|
|
}
|
|
|
|
|
2016-06-21 16:25:43 +02:00
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Collect all players where the name matches or not the specified one.
|
|
|
|
*/
|
2016-07-26 22:08:27 +02:00
|
|
|
static inline Array Player_AllWhereNameEquals(bool neg, bool cs, CSStr name)
|
2016-06-21 16:25:43 +02:00
|
|
|
{
|
|
|
|
SQMOD_VALID_NAME_STR(name)
|
|
|
|
// Remember the current stack size
|
|
|
|
const StackGuard sg;
|
|
|
|
// Allocate an empty array on the stack
|
|
|
|
sq_newarray(DefaultVM::Get(), 0);
|
|
|
|
// Process each entity in the pool
|
|
|
|
EachEquals(InstSpec< CPlayer >::CBegin(), InstSpec< CPlayer >::CEnd(),
|
|
|
|
ValidInstFunc< CPlayer >(), PlayerName(),
|
2016-07-26 22:08:27 +02:00
|
|
|
AppendElemFunc< CPlayer >(), name, !neg, cs);
|
2016-06-21 16:25:43 +02:00
|
|
|
// Return the array at the top of the stack
|
|
|
|
return Var< Array >(DefaultVM::Get(), -1).value;
|
|
|
|
}
|
2016-06-21 15:15:25 +02:00
|
|
|
|
2016-06-21 16:25:43 +02:00
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Collect all players where the name begins or not with the specified string.
|
|
|
|
*/
|
2016-07-26 22:08:27 +02:00
|
|
|
static inline Array Player_AllWhereNameBegins(bool neg, bool cs, CSStr name)
|
2016-06-21 14:17:08 +02:00
|
|
|
{
|
2016-06-21 16:25:43 +02:00
|
|
|
SQMOD_VALID_NAME_STR(name)
|
|
|
|
// Remember the current stack size
|
|
|
|
const StackGuard sg;
|
|
|
|
// Allocate an empty array on the stack
|
|
|
|
sq_newarray(DefaultVM::Get(), 0);
|
|
|
|
// Process each entity in the pool
|
|
|
|
EachBegins(InstSpec< CPlayer >::CBegin(), InstSpec< CPlayer >::CEnd(),
|
|
|
|
ValidInstFunc< CPlayer >(), PlayerName(),
|
2016-07-26 22:08:27 +02:00
|
|
|
AppendElemFunc< CPlayer >(), name, strlen(name), !neg, cs);
|
2016-06-21 16:25:43 +02:00
|
|
|
// Return the array at the top of the stack
|
|
|
|
return Var< Array >(DefaultVM::Get(), -1).value;
|
|
|
|
}
|
2016-06-21 14:17:08 +02:00
|
|
|
|
2016-06-21 16:25:43 +02:00
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Collect all players where the name ends or not with the specified string.
|
|
|
|
*/
|
2016-07-26 22:08:27 +02:00
|
|
|
static inline Array Player_AllWhereNameEnds(bool neg, bool cs, CSStr name)
|
2016-06-21 16:25:43 +02:00
|
|
|
{
|
|
|
|
SQMOD_VALID_NAME_STR(name)
|
|
|
|
// Remember the current stack size
|
|
|
|
const StackGuard sg;
|
|
|
|
// Allocate an empty array on the stack
|
|
|
|
sq_newarray(DefaultVM::Get(), 0);
|
|
|
|
// Process each entity in the pool
|
|
|
|
EachEnds(InstSpec< CPlayer >::CBegin(), InstSpec< CPlayer >::CEnd(),
|
|
|
|
ValidInstFunc< CPlayer >(), PlayerName(),
|
2016-07-26 22:08:27 +02:00
|
|
|
AppendElemFunc< CPlayer >(), name, strlen(name), !neg, cs);
|
2016-06-21 16:25:43 +02:00
|
|
|
// Return the array at the top of the stack
|
|
|
|
return Var< Array >(DefaultVM::Get(), -1).value;
|
|
|
|
}
|
2016-06-21 14:17:08 +02:00
|
|
|
|
2016-06-21 16:25:43 +02:00
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Collect all players where the name contains or not the specified string.
|
|
|
|
*/
|
2016-07-26 22:08:27 +02:00
|
|
|
static inline Array Player_AllWhereNameContains(bool neg, bool cs, CSStr name)
|
2016-06-21 16:25:43 +02:00
|
|
|
{
|
|
|
|
SQMOD_VALID_NAME_STR(name)
|
|
|
|
// Remember the current stack size
|
|
|
|
const StackGuard sg;
|
|
|
|
// Allocate an empty array on the stack
|
|
|
|
sq_newarray(DefaultVM::Get(), 0);
|
|
|
|
// Process each entity in the pool
|
|
|
|
EachContains(InstSpec< CPlayer >::CBegin(), InstSpec< CPlayer >::CEnd(),
|
|
|
|
ValidInstFunc< CPlayer >(), PlayerName(),
|
2016-07-26 22:08:27 +02:00
|
|
|
AppendElemFunc< CPlayer >(), name, !neg, cs);
|
2016-06-21 16:25:43 +02:00
|
|
|
// Return the array at the top of the stack
|
|
|
|
return Var< Array >(DefaultVM::Get(), -1).value;
|
|
|
|
}
|
2016-06-21 14:17:08 +02:00
|
|
|
|
2016-08-19 02:49:50 +02:00
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Collect all players where the name matches or not the specified filter.
|
|
|
|
*/
|
|
|
|
static inline Array Player_AllWhereNameMatches(bool neg, bool cs, CSStr name)
|
|
|
|
{
|
|
|
|
SQMOD_VALID_NAME_STR(name)
|
|
|
|
// Remember the current stack size
|
|
|
|
const StackGuard sg;
|
|
|
|
// Allocate an empty array on the stack
|
|
|
|
sq_newarray(DefaultVM::Get(), 0);
|
|
|
|
// Process each entity in the pool
|
|
|
|
EachMatches(InstSpec< CPlayer >::CBegin(), InstSpec< CPlayer >::CEnd(),
|
|
|
|
ValidInstFunc< CPlayer >(), PlayerName(),
|
|
|
|
AppendElemFunc< CPlayer >(), name, !neg, cs);
|
|
|
|
// Return the array at the top of the stack
|
|
|
|
return Var< Array >(DefaultVM::Get(), -1).value;
|
|
|
|
}
|
|
|
|
|
2016-06-21 16:25:43 +02:00
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the first player where the name matches or not the specified one.
|
|
|
|
*/
|
2017-02-21 20:24:59 +01:00
|
|
|
static inline LightObj Player_FirstWhereNameEquals(bool neg, bool cs, CSStr name)
|
2016-06-21 16:25:43 +02:00
|
|
|
{
|
|
|
|
SQMOD_VALID_NAME_STR(name)
|
|
|
|
// Create a new element receiver
|
|
|
|
RecvElemFunc< CPlayer > recv;
|
|
|
|
// Process each entity in the pool
|
|
|
|
FirstEquals(InstSpec< CPlayer >::CBegin(), InstSpec< CPlayer >::CEnd(),
|
2016-07-14 22:34:52 +02:00
|
|
|
ValidInstFunc< CPlayer >(), PlayerName(),
|
2016-07-26 22:08:27 +02:00
|
|
|
std::reference_wrapper< RecvElemFunc< CPlayer > >(recv), name, !neg, cs);
|
2016-06-21 16:25:43 +02:00
|
|
|
// Return the received element, if any
|
|
|
|
return recv.mObj;
|
|
|
|
}
|
2016-06-21 14:17:08 +02:00
|
|
|
|
2016-06-21 16:25:43 +02:00
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the first player where the name begins or not with the specified string.
|
|
|
|
*/
|
2017-02-21 20:24:59 +01:00
|
|
|
static inline LightObj Player_FirstWhereNameBegins(bool neg, bool cs, CSStr name)
|
2016-06-21 16:25:43 +02:00
|
|
|
{
|
|
|
|
SQMOD_VALID_NAME_STR(name)
|
|
|
|
// Create a new element receiver
|
|
|
|
RecvElemFunc< CPlayer > recv;
|
|
|
|
// Process each entity in the pool
|
|
|
|
FirstBegins(InstSpec< CPlayer >::CBegin(), InstSpec< CPlayer >::CEnd(),
|
2016-07-14 22:34:52 +02:00
|
|
|
ValidInstFunc< CPlayer >(), PlayerName(),
|
2016-07-26 22:08:27 +02:00
|
|
|
std::reference_wrapper< RecvElemFunc< CPlayer > >(recv), name, strlen(name), !neg, cs);
|
2016-06-21 16:25:43 +02:00
|
|
|
// Return the received element, if any
|
|
|
|
return recv.mObj;
|
|
|
|
}
|
2016-06-21 14:17:08 +02:00
|
|
|
|
2016-06-21 16:25:43 +02:00
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the first player where the name ends or not with the specified string.
|
|
|
|
*/
|
2017-02-21 20:24:59 +01:00
|
|
|
static inline LightObj Player_FirstWhereNameEnds(bool neg, bool cs, CSStr name)
|
2016-06-21 16:25:43 +02:00
|
|
|
{
|
|
|
|
SQMOD_VALID_NAME_STR(name)
|
|
|
|
// Create a new element receiver
|
|
|
|
RecvElemFunc< CPlayer > recv;
|
|
|
|
// Process each entity in the pool
|
|
|
|
FirstEnds(InstSpec< CPlayer >::CBegin(), InstSpec< CPlayer >::CEnd(),
|
2016-07-14 22:34:52 +02:00
|
|
|
ValidInstFunc< CPlayer >(), PlayerName(),
|
2016-07-26 22:08:27 +02:00
|
|
|
std::reference_wrapper< RecvElemFunc< CPlayer > >(recv), name, strlen(name), !neg, cs);
|
2016-06-21 16:25:43 +02:00
|
|
|
// Return the received element, if any
|
|
|
|
return recv.mObj;
|
|
|
|
}
|
2016-06-21 14:17:08 +02:00
|
|
|
|
2016-06-21 16:25:43 +02:00
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the first player where the name contains or not the specified string.
|
|
|
|
*/
|
2017-02-21 20:24:59 +01:00
|
|
|
static inline LightObj Player_FirstWhereNameContains(bool neg, bool cs, CSStr name)
|
2016-06-21 16:25:43 +02:00
|
|
|
{
|
|
|
|
SQMOD_VALID_NAME_STR(name)
|
|
|
|
// Create a new element receiver
|
|
|
|
RecvElemFunc< CPlayer > recv;
|
|
|
|
// Process each entity in the pool
|
|
|
|
FirstContains(InstSpec< CPlayer >::CBegin(), InstSpec< CPlayer >::CEnd(),
|
2016-07-14 22:34:52 +02:00
|
|
|
ValidInstFunc< CPlayer >(), PlayerName(),
|
2016-07-26 22:08:27 +02:00
|
|
|
std::reference_wrapper< RecvElemFunc< CPlayer > >(recv), name, !neg, cs);
|
2016-06-21 16:25:43 +02:00
|
|
|
// Return the received element, if any
|
|
|
|
return recv.mObj;
|
|
|
|
}
|
2016-06-21 14:17:08 +02:00
|
|
|
|
2016-08-19 02:49:50 +02:00
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the first player where the name matches or not the specified filter.
|
|
|
|
*/
|
2017-02-21 20:24:59 +01:00
|
|
|
static inline LightObj Player_FirstWhereNameMatches(bool neg, bool cs, CSStr name)
|
2016-08-19 02:49:50 +02:00
|
|
|
{
|
|
|
|
SQMOD_VALID_NAME_STR(name)
|
|
|
|
// Create a new element receiver
|
|
|
|
RecvElemFunc< CPlayer > recv;
|
|
|
|
// Process each entity in the pool
|
|
|
|
FirstMatches(InstSpec< CPlayer >::CBegin(), InstSpec< CPlayer >::CEnd(),
|
|
|
|
ValidInstFunc< CPlayer >(), PlayerName(),
|
|
|
|
std::reference_wrapper< RecvElemFunc< CPlayer > >(recv), name, !neg, cs);
|
|
|
|
// Return the received element, if any
|
|
|
|
return recv.mObj;
|
|
|
|
}
|
|
|
|
|
2016-06-21 16:25:43 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Process all entities of this type where the name matches or not the specified one.
|
|
|
|
*/
|
2017-02-21 20:24:59 +01:00
|
|
|
static inline Uint32 Player_EachWhereNameEquals(bool neg, bool cs, CSStr name, LightObj & env, Function & func)
|
2016-06-21 16:25:43 +02:00
|
|
|
{
|
|
|
|
SQMOD_VALID_NAME_STR(name)
|
|
|
|
// Create a new element forwarder
|
|
|
|
ForwardElemFunc< CPlayer > fwd(env, func);
|
|
|
|
// Process each entity in the pool
|
|
|
|
EachEquals(InstSpec< CPlayer >::CBegin(), InstSpec< CPlayer >::CEnd(),
|
2016-07-14 22:34:52 +02:00
|
|
|
ValidInstFunc< CPlayer >(), PlayerName(),
|
2016-07-26 22:08:27 +02:00
|
|
|
std::reference_wrapper< ForwardElemFunc< CPlayer > >(fwd), name, !neg, cs);
|
2016-06-21 16:25:43 +02:00
|
|
|
// Return the forward count
|
|
|
|
return fwd.mCount;
|
|
|
|
}
|
2016-06-21 14:17:08 +02:00
|
|
|
|
2016-10-25 15:07:10 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Process all entities of this type where the name matches or not the specified one.
|
|
|
|
*/
|
2017-02-21 20:24:59 +01:00
|
|
|
static inline Uint32 Player_EachWhereNameEqualsData(bool neg, bool cs, CSStr name, LightObj & data, LightObj & env, Function & func)
|
2016-10-25 15:07:10 +02:00
|
|
|
{
|
|
|
|
SQMOD_VALID_NAME_STR(name)
|
|
|
|
// Create a new element forwarder
|
|
|
|
ForwardElemDataFunc< CPlayer > fwd(data, env, func);
|
|
|
|
// Process each entity in the pool
|
|
|
|
EachEquals(InstSpec< CPlayer >::CBegin(), InstSpec< CPlayer >::CEnd(),
|
|
|
|
ValidInstFunc< CPlayer >(), PlayerName(),
|
|
|
|
std::reference_wrapper< ForwardElemDataFunc< CPlayer > >(fwd), name, !neg, cs);
|
|
|
|
// Return the forward count
|
|
|
|
return fwd.mCount;
|
|
|
|
}
|
|
|
|
|
2016-06-21 16:25:43 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Process all entities of this type where the name begins with the specified string.
|
|
|
|
*/
|
2017-02-21 20:24:59 +01:00
|
|
|
static inline Uint32 Player_EachWhereNameBegins(bool neg, bool cs, CSStr name, LightObj & env, Function & func)
|
2016-06-21 16:25:43 +02:00
|
|
|
{
|
|
|
|
SQMOD_VALID_NAME_STR(name)
|
|
|
|
// Create a new element forwarder
|
|
|
|
ForwardElemFunc< CPlayer > fwd(env, func);
|
|
|
|
// Process each entity in the pool
|
|
|
|
EachBegins(InstSpec< CPlayer >::CBegin(), InstSpec< CPlayer >::CEnd(),
|
2016-07-14 22:34:52 +02:00
|
|
|
ValidInstFunc< CPlayer >(), PlayerName(),
|
2016-07-26 22:08:27 +02:00
|
|
|
std::reference_wrapper< ForwardElemFunc< CPlayer > >(fwd), name, strlen(name), !neg, cs);
|
2016-06-21 16:25:43 +02:00
|
|
|
// Return the forward count
|
|
|
|
return fwd.mCount;
|
|
|
|
}
|
2016-06-21 14:17:08 +02:00
|
|
|
|
2016-10-25 15:07:10 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Process all entities of this type where the name begins with the specified string.
|
|
|
|
*/
|
2017-02-21 20:24:59 +01:00
|
|
|
static inline Uint32 Player_EachWhereNameBeginsData(bool neg, bool cs, CSStr name, LightObj & data, LightObj & env, Function & func)
|
2016-10-25 15:07:10 +02:00
|
|
|
{
|
|
|
|
SQMOD_VALID_NAME_STR(name)
|
|
|
|
// Create a new element forwarder
|
|
|
|
ForwardElemDataFunc< CPlayer > fwd(data, env, func);
|
|
|
|
// Process each entity in the pool
|
|
|
|
EachBegins(InstSpec< CPlayer >::CBegin(), InstSpec< CPlayer >::CEnd(),
|
|
|
|
ValidInstFunc< CPlayer >(), PlayerName(),
|
|
|
|
std::reference_wrapper< ForwardElemDataFunc< CPlayer > >(fwd), name, strlen(name), !neg, cs);
|
|
|
|
// Return the forward count
|
|
|
|
return fwd.mCount;
|
|
|
|
}
|
|
|
|
|
2016-06-21 16:25:43 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Process all entities of this type where the name ends or not with the specified string.
|
|
|
|
*/
|
2017-02-21 20:24:59 +01:00
|
|
|
static inline Uint32 Player_EachWhereNameEnds(bool neg, bool cs, CSStr name, LightObj & env, Function & func)
|
2016-06-21 16:25:43 +02:00
|
|
|
{
|
|
|
|
SQMOD_VALID_NAME_STR(name)
|
|
|
|
// Create a new element forwarder
|
|
|
|
ForwardElemFunc< CPlayer > fwd(env, func);
|
|
|
|
// Process each entity in the pool
|
|
|
|
EachEnds(InstSpec< CPlayer >::CBegin(), InstSpec< CPlayer >::CEnd(),
|
2016-07-14 22:34:52 +02:00
|
|
|
ValidInstFunc< CPlayer >(), PlayerName(),
|
2016-07-26 22:08:27 +02:00
|
|
|
std::reference_wrapper< ForwardElemFunc< CPlayer > >(fwd), name, strlen(name), !neg, cs);
|
2016-06-21 16:25:43 +02:00
|
|
|
// Return the forward count
|
|
|
|
return fwd.mCount;
|
|
|
|
}
|
|
|
|
|
2016-10-25 15:07:10 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Process all entities of this type where the name ends or not with the specified string.
|
|
|
|
*/
|
2017-02-21 20:24:59 +01:00
|
|
|
static inline Uint32 Player_EachWhereNameEndsData(bool neg, bool cs, CSStr name, LightObj & data, LightObj & env, Function & func)
|
2016-10-25 15:07:10 +02:00
|
|
|
{
|
|
|
|
SQMOD_VALID_NAME_STR(name)
|
|
|
|
// Create a new element forwarder
|
|
|
|
ForwardElemDataFunc< CPlayer > fwd(data, env, func);
|
|
|
|
// Process each entity in the pool
|
|
|
|
EachEnds(InstSpec< CPlayer >::CBegin(), InstSpec< CPlayer >::CEnd(),
|
|
|
|
ValidInstFunc< CPlayer >(), PlayerName(),
|
|
|
|
std::reference_wrapper< ForwardElemDataFunc< CPlayer > >(fwd), name, strlen(name), !neg, cs);
|
|
|
|
// Return the forward count
|
|
|
|
return fwd.mCount;
|
|
|
|
}
|
|
|
|
|
2016-06-21 16:25:43 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Process all entities of this type where the name contains the specified string.
|
|
|
|
*/
|
2017-02-21 20:24:59 +01:00
|
|
|
static inline Uint32 Player_EachWhereNameContains(bool neg, bool cs, CSStr name, LightObj & env, Function & func)
|
2016-06-21 16:25:43 +02:00
|
|
|
{
|
|
|
|
SQMOD_VALID_NAME_STR(name)
|
|
|
|
// Create a new element forwarder
|
|
|
|
ForwardElemFunc< CPlayer > fwd(env, func);
|
|
|
|
// Process each entity in the pool
|
|
|
|
EachContains(InstSpec< CPlayer >::CBegin(), InstSpec< CPlayer >::CEnd(),
|
2016-07-14 22:34:52 +02:00
|
|
|
ValidInstFunc< CPlayer >(), PlayerName(),
|
2016-07-26 22:08:27 +02:00
|
|
|
std::reference_wrapper< ForwardElemFunc< CPlayer > >(fwd), name, !neg, cs);
|
2016-06-21 16:25:43 +02:00
|
|
|
// Return the forward count
|
|
|
|
return fwd.mCount;
|
|
|
|
}
|
|
|
|
|
2016-10-25 15:07:10 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Process all entities of this type where the name contains the specified string.
|
|
|
|
*/
|
2017-02-21 20:24:59 +01:00
|
|
|
static inline Uint32 Player_EachWhereNameContainsData(bool neg, bool cs, CSStr name, LightObj & data, LightObj & env, Function & func)
|
2016-10-25 15:07:10 +02:00
|
|
|
{
|
|
|
|
SQMOD_VALID_NAME_STR(name)
|
|
|
|
// Create a new element forwarder
|
|
|
|
ForwardElemDataFunc< CPlayer > fwd(data, env, func);
|
|
|
|
// Process each entity in the pool
|
|
|
|
EachContains(InstSpec< CPlayer >::CBegin(), InstSpec< CPlayer >::CEnd(),
|
|
|
|
ValidInstFunc< CPlayer >(), PlayerName(),
|
|
|
|
std::reference_wrapper< ForwardElemDataFunc< CPlayer > >(fwd), name, !neg, cs);
|
|
|
|
// Return the forward count
|
|
|
|
return fwd.mCount;
|
|
|
|
}
|
|
|
|
|
2016-08-19 02:49:50 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Process all entities of this type where the name matches the specified filter.
|
|
|
|
*/
|
2017-02-21 20:24:59 +01:00
|
|
|
static inline Uint32 Player_EachWhereNameMatches(bool neg, bool cs, CSStr name, LightObj & env, Function & func)
|
2016-08-19 02:49:50 +02:00
|
|
|
{
|
|
|
|
SQMOD_VALID_NAME_STR(name)
|
|
|
|
// Create a new element forwarder
|
|
|
|
ForwardElemFunc< CPlayer > fwd(env, func);
|
|
|
|
// Process each entity in the pool
|
|
|
|
EachMatches(InstSpec< CPlayer >::CBegin(), InstSpec< CPlayer >::CEnd(),
|
|
|
|
ValidInstFunc< CPlayer >(), PlayerName(),
|
|
|
|
std::reference_wrapper< ForwardElemFunc< CPlayer > >(fwd), name, !neg, cs);
|
|
|
|
// Return the forward count
|
|
|
|
return fwd.mCount;
|
|
|
|
}
|
|
|
|
|
2016-10-25 15:07:10 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Process all entities of this type where the name matches the specified filter.
|
|
|
|
*/
|
2017-02-21 20:24:59 +01:00
|
|
|
static inline Uint32 Player_EachWhereNameMatchesData(bool neg, bool cs, CSStr name, LightObj & data, LightObj & env, Function & func)
|
2016-10-25 15:07:10 +02:00
|
|
|
{
|
|
|
|
SQMOD_VALID_NAME_STR(name)
|
|
|
|
// Create a new element forwarder
|
|
|
|
ForwardElemDataFunc< CPlayer > fwd(data, env, func);
|
|
|
|
// Process each entity in the pool
|
|
|
|
EachMatches(InstSpec< CPlayer >::CBegin(), InstSpec< CPlayer >::CEnd(),
|
|
|
|
ValidInstFunc< CPlayer >(), PlayerName(),
|
|
|
|
std::reference_wrapper< ForwardElemDataFunc< CPlayer > >(fwd), name, !neg, cs);
|
|
|
|
// Return the forward count
|
|
|
|
return fwd.mCount;
|
|
|
|
}
|
|
|
|
|
2016-07-17 12:33:42 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Count all entities of this type where the name matches or not the specified one.
|
|
|
|
*/
|
2016-07-26 22:08:27 +02:00
|
|
|
static inline Uint32 Player_CountWhereNameEquals(bool neg, bool cs, CSStr name)
|
2016-07-17 12:33:42 +02:00
|
|
|
{
|
|
|
|
SQMOD_VALID_NAME_STR(name)
|
|
|
|
// Create a new element counter
|
|
|
|
CountElemFunc< CPlayer > cnt;
|
|
|
|
// Process each entity in the pool
|
|
|
|
EachEquals(InstSpec< CPlayer >::CBegin(), InstSpec< CPlayer >::CEnd(),
|
|
|
|
ValidInstFunc< CPlayer >(), PlayerName(),
|
2016-07-26 22:08:27 +02:00
|
|
|
std::reference_wrapper< CountElemFunc< CPlayer > >(cnt), name, !neg, cs);
|
2016-07-17 12:33:42 +02:00
|
|
|
// Return the count
|
|
|
|
return cnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Count all entities of this type where the name begins with the specified string.
|
|
|
|
*/
|
2016-07-26 22:08:27 +02:00
|
|
|
static inline Uint32 Player_CountWhereNameBegins(bool neg, bool cs, CSStr name)
|
2016-07-17 12:33:42 +02:00
|
|
|
{
|
|
|
|
SQMOD_VALID_NAME_STR(name)
|
|
|
|
// Create a new element counter
|
|
|
|
CountElemFunc< CPlayer > cnt;
|
|
|
|
// Process each entity in the pool
|
|
|
|
EachBegins(InstSpec< CPlayer >::CBegin(), InstSpec< CPlayer >::CEnd(),
|
|
|
|
ValidInstFunc< CPlayer >(), PlayerName(),
|
2016-07-26 22:08:27 +02:00
|
|
|
std::reference_wrapper< CountElemFunc< CPlayer > >(cnt), name, strlen(name), !neg, cs);
|
2016-07-17 12:33:42 +02:00
|
|
|
// Return the count
|
|
|
|
return cnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Count all entities of this type where the name ends or not with the specified string.
|
|
|
|
*/
|
2016-07-26 22:08:27 +02:00
|
|
|
static inline Uint32 Player_CountWhereNameEnds(bool neg, bool cs, CSStr name)
|
2016-07-17 12:33:42 +02:00
|
|
|
{
|
|
|
|
SQMOD_VALID_NAME_STR(name)
|
|
|
|
// Create a new element counter
|
|
|
|
CountElemFunc< CPlayer > cnt;
|
|
|
|
// Process each entity in the pool
|
|
|
|
EachEnds(InstSpec< CPlayer >::CBegin(), InstSpec< CPlayer >::CEnd(),
|
|
|
|
ValidInstFunc< CPlayer >(), PlayerName(),
|
2016-07-26 22:08:27 +02:00
|
|
|
std::reference_wrapper< CountElemFunc< CPlayer > >(cnt), name, strlen(name), !neg, cs);
|
2016-07-17 12:33:42 +02:00
|
|
|
// Return the count
|
|
|
|
return cnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Count all entities of this type where the name contains the specified string.
|
|
|
|
*/
|
2016-07-26 22:08:27 +02:00
|
|
|
static inline Uint32 Player_CountWhereNameContains(bool neg, bool cs, CSStr name)
|
2016-07-17 12:33:42 +02:00
|
|
|
{
|
|
|
|
SQMOD_VALID_NAME_STR(name)
|
|
|
|
// Create a new element counter
|
|
|
|
CountElemFunc< CPlayer > cnt;
|
|
|
|
// Process each entity in the pool
|
|
|
|
EachContains(InstSpec< CPlayer >::CBegin(), InstSpec< CPlayer >::CEnd(),
|
|
|
|
ValidInstFunc< CPlayer >(), PlayerName(),
|
2016-07-26 22:08:27 +02:00
|
|
|
std::reference_wrapper< CountElemFunc< CPlayer > >(cnt), name, !neg, cs);
|
2016-07-17 12:33:42 +02:00
|
|
|
// Return the count
|
|
|
|
return cnt;
|
|
|
|
}
|
|
|
|
|
2016-08-19 02:49:50 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Count all entities of this type where the name matches the specified filter.
|
|
|
|
*/
|
|
|
|
static inline Uint32 Player_CountWhereNameMatches(bool neg, bool cs, CSStr name)
|
|
|
|
{
|
|
|
|
SQMOD_VALID_NAME_STR(name)
|
|
|
|
// Create a new element counter
|
|
|
|
CountElemFunc< CPlayer > cnt;
|
|
|
|
// Process each entity in the pool
|
|
|
|
EachMatches(InstSpec< CPlayer >::CBegin(), InstSpec< CPlayer >::CEnd(),
|
|
|
|
ValidInstFunc< CPlayer >(), PlayerName(),
|
|
|
|
std::reference_wrapper< CountElemFunc< CPlayer > >(cnt), name, !neg, cs);
|
|
|
|
// Return the count
|
|
|
|
return cnt;
|
|
|
|
}
|
|
|
|
|
2016-06-21 16:25:43 +02:00
|
|
|
// ================================================================================================
|
|
|
|
void Register(HSQUIRRELVM vm)
|
|
|
|
{
|
2016-07-17 12:33:42 +02:00
|
|
|
Table collect_ns(vm);
|
2016-06-21 14:17:08 +02:00
|
|
|
|
2016-07-17 12:33:42 +02:00
|
|
|
collect_ns.Bind(_SC("Blip"), Table(vm)
|
2016-06-21 15:04:21 +02:00
|
|
|
.Func(_SC("Active"), &Entity< CBlip >::AllActive)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CBlip >::AllWhereTagEquals)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CBlip >::AllWhereTagBegins)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CBlip >::AllWhereTagEnds)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CBlip >::AllWhereTagContains)
|
2016-08-19 02:49:50 +02:00
|
|
|
.Func(_SC("TagMatches"), &Entity< CBlip >::AllWhereTagMatches)
|
2016-06-21 14:17:08 +02:00
|
|
|
);
|
|
|
|
|
2016-07-17 12:33:42 +02:00
|
|
|
collect_ns.Bind(_SC("Checkpoint"), Table(vm)
|
2016-06-21 15:04:21 +02:00
|
|
|
.Func(_SC("Active"), &Entity< CCheckpoint >::AllActive)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CCheckpoint >::AllWhereTagEquals)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CCheckpoint >::AllWhereTagBegins)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CCheckpoint >::AllWhereTagEnds)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CCheckpoint >::AllWhereTagContains)
|
2016-08-19 02:49:50 +02:00
|
|
|
.Func(_SC("TagMatches"), &Entity< CCheckpoint >::AllWhereTagMatches)
|
2016-06-21 14:17:08 +02:00
|
|
|
);
|
|
|
|
|
2016-07-17 12:33:42 +02:00
|
|
|
collect_ns.Bind(_SC("Keybind"), Table(vm)
|
2016-06-21 15:04:21 +02:00
|
|
|
.Func(_SC("Active"), &Entity< CKeybind >::AllActive)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CKeybind >::AllWhereTagEquals)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CKeybind >::AllWhereTagBegins)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CKeybind >::AllWhereTagEnds)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CKeybind >::AllWhereTagContains)
|
2016-08-19 02:49:50 +02:00
|
|
|
.Func(_SC("TagMatches"), &Entity< CKeybind >::AllWhereTagMatches)
|
2016-06-21 14:17:08 +02:00
|
|
|
);
|
|
|
|
|
2016-07-17 12:33:42 +02:00
|
|
|
collect_ns.Bind(_SC("Object"), Table(vm)
|
2016-06-21 15:04:21 +02:00
|
|
|
.Func(_SC("Active"), &Entity< CObject >::AllActive)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CObject >::AllWhereTagEquals)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CObject >::AllWhereTagBegins)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CObject >::AllWhereTagEnds)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CObject >::AllWhereTagContains)
|
2016-08-19 02:49:50 +02:00
|
|
|
.Func(_SC("TagMatches"), &Entity< CObject >::AllWhereTagMatches)
|
2016-06-21 14:17:08 +02:00
|
|
|
);
|
|
|
|
|
2016-07-17 12:33:42 +02:00
|
|
|
collect_ns.Bind(_SC("Pickup"), Table(vm)
|
2016-06-21 15:04:21 +02:00
|
|
|
.Func(_SC("Active"), &Entity< CPickup >::AllActive)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CPickup >::AllWhereTagEquals)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CPickup >::AllWhereTagBegins)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CPickup >::AllWhereTagEnds)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CPickup >::AllWhereTagContains)
|
2016-08-19 02:49:50 +02:00
|
|
|
.Func(_SC("TagMatches"), &Entity< CPickup >::AllWhereTagMatches)
|
2016-06-21 14:17:08 +02:00
|
|
|
);
|
|
|
|
|
2016-07-17 12:33:42 +02:00
|
|
|
collect_ns.Bind(_SC("Player"), Table(vm)
|
2016-06-21 15:04:21 +02:00
|
|
|
.Func(_SC("Active"), &Entity< CPlayer >::AllActive)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CPlayer >::AllWhereTagEquals)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CPlayer >::AllWhereTagBegins)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CPlayer >::AllWhereTagEnds)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CPlayer >::AllWhereTagContains)
|
2016-08-19 02:49:50 +02:00
|
|
|
.Func(_SC("TagMatches"), &Entity< CPlayer >::AllWhereTagMatches)
|
2016-06-21 16:25:43 +02:00
|
|
|
.Func(_SC("NameEquals"), &Player_AllWhereNameEquals)
|
|
|
|
.Func(_SC("NameBegins"), &Player_AllWhereNameBegins)
|
|
|
|
.Func(_SC("NameEnds"), &Player_AllWhereNameEnds)
|
|
|
|
.Func(_SC("NameContains"), &Player_AllWhereNameContains)
|
2016-08-19 02:49:50 +02:00
|
|
|
.Func(_SC("NameMatches"), &Player_AllWhereNameMatches)
|
2016-06-21 14:17:08 +02:00
|
|
|
);
|
|
|
|
|
2016-07-17 12:33:42 +02:00
|
|
|
collect_ns.Bind(_SC("Vehicle"), Table(vm)
|
2016-06-21 15:04:21 +02:00
|
|
|
.Func(_SC("Active"), &Entity< CVehicle >::AllActive)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CVehicle >::AllWhereTagEquals)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CVehicle >::AllWhereTagBegins)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CVehicle >::AllWhereTagEnds)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CVehicle >::AllWhereTagContains)
|
2016-08-19 02:49:50 +02:00
|
|
|
.Func(_SC("TagMatches"), &Entity< CVehicle >::AllWhereTagMatches)
|
2016-06-21 14:17:08 +02:00
|
|
|
);
|
|
|
|
|
2016-07-17 12:33:42 +02:00
|
|
|
RootTable(vm).Bind(_SC("SqCollect"), collect_ns);
|
2016-06-21 14:17:08 +02:00
|
|
|
|
2016-07-17 12:33:42 +02:00
|
|
|
Table find_ns(vm);
|
2016-06-21 16:25:43 +02:00
|
|
|
|
2016-07-17 12:33:42 +02:00
|
|
|
find_ns.Bind(_SC("Blip"), Table(vm)
|
2016-06-21 16:25:43 +02:00
|
|
|
.Func(_SC("WithID"), &Entity< CBlip >::FindByID)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CBlip >::FirstWhereTagEquals)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CBlip >::FirstWhereTagBegins)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CBlip >::FirstWhereTagEnds)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CBlip >::FirstWhereTagContains)
|
2016-08-19 02:49:50 +02:00
|
|
|
.Func(_SC("TagMatches"), &Entity< CBlip >::FirstWhereTagMatches)
|
2016-06-21 16:25:43 +02:00
|
|
|
.Func(_SC("WithSprID"), &Blip_FindBySprID)
|
|
|
|
);
|
|
|
|
|
2016-07-17 12:33:42 +02:00
|
|
|
find_ns.Bind(_SC("Checkpoint"), Table(vm)
|
2016-06-21 16:25:43 +02:00
|
|
|
.Func(_SC("WithID"), &Entity< CCheckpoint >::FindByID)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CCheckpoint >::FirstWhereTagEquals)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CCheckpoint >::FirstWhereTagBegins)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CCheckpoint >::FirstWhereTagEnds)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CCheckpoint >::FirstWhereTagContains)
|
2016-08-19 02:49:50 +02:00
|
|
|
.Func(_SC("TagMatches"), &Entity< CCheckpoint >::FirstWhereTagMatches)
|
2016-06-21 16:25:43 +02:00
|
|
|
);
|
|
|
|
|
2016-07-17 12:33:42 +02:00
|
|
|
find_ns.Bind(_SC("Keybind"), Table(vm)
|
2016-06-21 16:25:43 +02:00
|
|
|
.Func(_SC("WithID"), &Entity< CKeybind >::FindByID)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CKeybind >::FirstWhereTagEquals)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CKeybind >::FirstWhereTagBegins)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CKeybind >::FirstWhereTagEnds)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CKeybind >::FirstWhereTagContains)
|
2016-08-19 02:49:50 +02:00
|
|
|
.Func(_SC("TagMatches"), &Entity< CKeybind >::FirstWhereTagMatches)
|
2016-06-21 16:25:43 +02:00
|
|
|
);
|
|
|
|
|
2016-07-17 12:33:42 +02:00
|
|
|
find_ns.Bind(_SC("Object"), Table(vm)
|
2016-06-21 16:25:43 +02:00
|
|
|
.Func(_SC("WithID"), &Entity< CObject >::FindByID)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CObject >::FirstWhereTagEquals)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CObject >::FirstWhereTagBegins)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CObject >::FirstWhereTagEnds)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CObject >::FirstWhereTagContains)
|
2016-08-19 02:49:50 +02:00
|
|
|
.Func(_SC("TagMatches"), &Entity< CObject >::FirstWhereTagMatches)
|
2016-06-21 16:25:43 +02:00
|
|
|
);
|
|
|
|
|
2016-07-17 12:33:42 +02:00
|
|
|
find_ns.Bind(_SC("Pickup"), Table(vm)
|
2016-06-21 16:25:43 +02:00
|
|
|
.Func(_SC("WithID"), &Entity< CPickup >::FindByID)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CPickup >::FirstWhereTagEquals)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CPickup >::FirstWhereTagBegins)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CPickup >::FirstWhereTagEnds)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CPickup >::FirstWhereTagContains)
|
2016-08-19 02:49:50 +02:00
|
|
|
.Func(_SC("TagMatches"), &Entity< CPickup >::FirstWhereTagMatches)
|
2016-06-21 16:25:43 +02:00
|
|
|
);
|
|
|
|
|
2016-07-17 12:33:42 +02:00
|
|
|
find_ns.Bind(_SC("Player"), Table(vm)
|
2016-06-21 16:25:43 +02:00
|
|
|
.Func(_SC("WithID"), &Entity< CPlayer >::FindByID)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CPlayer >::FirstWhereTagEquals)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CPlayer >::FirstWhereTagBegins)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CPlayer >::FirstWhereTagEnds)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CPlayer >::FirstWhereTagContains)
|
2016-08-19 02:49:50 +02:00
|
|
|
.Func(_SC("TagMatches"), &Entity< CPlayer >::FirstWhereTagMatches)
|
2016-07-10 22:29:45 +02:00
|
|
|
.Func(_SC("NameEquals"), &Player_FirstWhereNameEquals)
|
|
|
|
.Func(_SC("NameBegins"), &Player_FirstWhereNameBegins)
|
|
|
|
.Func(_SC("NameEnds"), &Player_FirstWhereNameEnds)
|
|
|
|
.Func(_SC("NameContains"), &Player_FirstWhereNameContains)
|
2016-08-19 02:49:50 +02:00
|
|
|
.Func(_SC("NameMatches"), &Player_FirstWhereNameMatches)
|
2016-06-21 16:25:43 +02:00
|
|
|
);
|
|
|
|
|
2016-07-17 12:33:42 +02:00
|
|
|
find_ns.Bind(_SC("Vehicle"), Table(vm)
|
2016-06-21 16:25:43 +02:00
|
|
|
.Func(_SC("WithID"), &Entity< CVehicle >::FindByID)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CVehicle >::FirstWhereTagEquals)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CVehicle >::FirstWhereTagBegins)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CVehicle >::FirstWhereTagEnds)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CVehicle >::FirstWhereTagContains)
|
2016-08-19 02:49:50 +02:00
|
|
|
.Func(_SC("TagMatches"), &Entity< CVehicle >::FirstWhereTagMatches)
|
2016-06-21 16:25:43 +02:00
|
|
|
);
|
|
|
|
|
2016-07-17 12:33:42 +02:00
|
|
|
RootTable(vm).Bind(_SC("SqFind"), find_ns);
|
2016-06-21 16:25:43 +02:00
|
|
|
|
2016-07-17 12:33:42 +02:00
|
|
|
Table each_ns(vm);
|
2016-06-21 14:17:08 +02:00
|
|
|
|
2016-07-17 12:33:42 +02:00
|
|
|
each_ns.Bind(_SC("Blip"), Table(vm)
|
2016-10-31 17:34:27 +01:00
|
|
|
.Func(_SC("Active"), &Entity< CBlip >::EachActive)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CBlip >::EachWhereTagEquals)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CBlip >::EachWhereTagBegins)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CBlip >::EachWhereTagEnds)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CBlip >::EachWhereTagContains)
|
|
|
|
.Func(_SC("TagMatches"), &Entity< CBlip >::EachWhereTagMatches)
|
2016-06-21 14:17:08 +02:00
|
|
|
);
|
|
|
|
|
2016-07-17 12:33:42 +02:00
|
|
|
each_ns.Bind(_SC("Checkpoint"), Table(vm)
|
2016-10-31 17:34:27 +01:00
|
|
|
.Func(_SC("Active"), &Entity< CCheckpoint >::EachActive)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CCheckpoint >::EachWhereTagEquals)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CCheckpoint >::EachWhereTagBegins)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CCheckpoint >::EachWhereTagEnds)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CCheckpoint >::EachWhereTagContains)
|
|
|
|
.Func(_SC("TagMatches"), &Entity< CCheckpoint >::EachWhereTagMatches)
|
2016-06-21 14:17:08 +02:00
|
|
|
);
|
|
|
|
|
2016-07-17 12:33:42 +02:00
|
|
|
each_ns.Bind(_SC("Keybind"), Table(vm)
|
2016-10-31 17:34:27 +01:00
|
|
|
.Func(_SC("Active"), &Entity< CKeybind >::EachActive)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CKeybind >::EachWhereTagEquals)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CKeybind >::EachWhereTagBegins)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CKeybind >::EachWhereTagEnds)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CKeybind >::EachWhereTagContains)
|
|
|
|
.Func(_SC("TagMatches"), &Entity< CKeybind >::EachWhereTagMatches)
|
2016-06-21 14:17:08 +02:00
|
|
|
);
|
|
|
|
|
2016-07-17 12:33:42 +02:00
|
|
|
each_ns.Bind(_SC("Object"), Table(vm)
|
2016-10-31 17:34:27 +01:00
|
|
|
.Func(_SC("Active"), &Entity< CObject >::EachActive)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CObject >::EachWhereTagEquals)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CObject >::EachWhereTagBegins)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CObject >::EachWhereTagEnds)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CObject >::EachWhereTagContains)
|
|
|
|
.Func(_SC("TagMatches"), &Entity< CObject >::EachWhereTagMatches)
|
2016-06-21 14:17:08 +02:00
|
|
|
);
|
|
|
|
|
2016-07-17 12:33:42 +02:00
|
|
|
each_ns.Bind(_SC("Pickup"), Table(vm)
|
2016-10-31 17:34:27 +01:00
|
|
|
.Func(_SC("Active"), &Entity< CPickup >::EachActive)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CPickup >::EachWhereTagEquals)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CPickup >::EachWhereTagBegins)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CPickup >::EachWhereTagEnds)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CPickup >::EachWhereTagContains)
|
|
|
|
.Func(_SC("TagMatches"), &Entity< CPickup >::EachWhereTagMatches)
|
2016-06-21 14:17:08 +02:00
|
|
|
);
|
|
|
|
|
2016-07-17 12:33:42 +02:00
|
|
|
each_ns.Bind(_SC("Player"), Table(vm)
|
2016-10-31 17:34:27 +01:00
|
|
|
.Func(_SC("Active"), &Entity< CPlayer >::EachActive)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CPlayer >::EachWhereTagEquals)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CPlayer >::EachWhereTagBegins)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CPlayer >::EachWhereTagEnds)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CPlayer >::EachWhereTagContains)
|
|
|
|
.Func(_SC("TagMatches"), &Entity< CPlayer >::EachWhereTagMatches)
|
|
|
|
.Func(_SC("NameEquals"), &Player_EachWhereNameEquals)
|
|
|
|
.Func(_SC("NameBegins"), &Player_EachWhereNameBegins)
|
|
|
|
.Func(_SC("NameEnds"), &Player_EachWhereNameEnds)
|
|
|
|
.Func(_SC("NameContains"), &Player_EachWhereNameContains)
|
|
|
|
.Func(_SC("NameMatches"), &Player_EachWhereNameMatches)
|
2016-06-21 14:17:08 +02:00
|
|
|
);
|
|
|
|
|
2016-07-17 12:33:42 +02:00
|
|
|
each_ns.Bind(_SC("Vehicle"), Table(vm)
|
2016-10-31 17:34:27 +01:00
|
|
|
.Func(_SC("Active"), &Entity< CVehicle >::EachActive)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CVehicle >::EachWhereTagEquals)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CVehicle >::EachWhereTagBegins)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CVehicle >::EachWhereTagEnds)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CVehicle >::EachWhereTagContains)
|
|
|
|
.Func(_SC("TagMatches"), &Entity< CVehicle >::EachWhereTagMatches)
|
2016-06-21 14:17:08 +02:00
|
|
|
);
|
|
|
|
|
2016-07-17 12:33:42 +02:00
|
|
|
RootTable(vm).Bind(_SC("SqForeach"), each_ns);
|
|
|
|
|
2016-10-31 17:34:27 +01:00
|
|
|
Table exeach_ns(vm);
|
|
|
|
|
|
|
|
exeach_ns.Bind(_SC("Blip"), Table(vm)
|
|
|
|
.Func(_SC("Active"), &Entity< CBlip >::EachActiveData)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CBlip >::EachWhereTagEqualsData)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CBlip >::EachWhereTagBeginsData)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CBlip >::EachWhereTagEndsData)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CBlip >::EachWhereTagContainsData)
|
|
|
|
.Func(_SC("TagMatches"), &Entity< CBlip >::EachWhereTagMatchesData)
|
|
|
|
);
|
|
|
|
|
|
|
|
exeach_ns.Bind(_SC("Checkpoint"), Table(vm)
|
|
|
|
.Func(_SC("Active"), &Entity< CCheckpoint >::EachActiveData)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CCheckpoint >::EachWhereTagEqualsData)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CCheckpoint >::EachWhereTagBeginsData)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CCheckpoint >::EachWhereTagEndsData)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CCheckpoint >::EachWhereTagContainsData)
|
|
|
|
.Func(_SC("TagMatches"), &Entity< CCheckpoint >::EachWhereTagMatchesData)
|
|
|
|
);
|
|
|
|
|
|
|
|
exeach_ns.Bind(_SC("Keybind"), Table(vm)
|
|
|
|
.Func(_SC("Active"), &Entity< CKeybind >::EachActiveData)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CKeybind >::EachWhereTagEqualsData)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CKeybind >::EachWhereTagBeginsData)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CKeybind >::EachWhereTagEndsData)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CKeybind >::EachWhereTagContainsData)
|
|
|
|
.Func(_SC("TagMatches"), &Entity< CKeybind >::EachWhereTagMatchesData)
|
|
|
|
);
|
|
|
|
|
|
|
|
exeach_ns.Bind(_SC("Object"), Table(vm)
|
|
|
|
.Func(_SC("Active"), &Entity< CObject >::EachActiveData)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CObject >::EachWhereTagEqualsData)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CObject >::EachWhereTagBeginsData)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CObject >::EachWhereTagEndsData)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CObject >::EachWhereTagContainsData)
|
|
|
|
.Func(_SC("TagMatches"), &Entity< CObject >::EachWhereTagMatchesData)
|
|
|
|
);
|
|
|
|
|
|
|
|
exeach_ns.Bind(_SC("Pickup"), Table(vm)
|
|
|
|
.Func(_SC("Active"), &Entity< CPickup >::EachActiveData)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CPickup >::EachWhereTagEqualsData)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CPickup >::EachWhereTagBeginsData)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CPickup >::EachWhereTagEndsData)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CPickup >::EachWhereTagContainsData)
|
|
|
|
.Func(_SC("TagMatches"), &Entity< CPickup >::EachWhereTagMatchesData)
|
|
|
|
);
|
|
|
|
|
|
|
|
exeach_ns.Bind(_SC("Player"), Table(vm)
|
|
|
|
.Func(_SC("Active"), &Entity< CPlayer >::EachActiveData)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CPlayer >::EachWhereTagEqualsData)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CPlayer >::EachWhereTagBeginsData)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CPlayer >::EachWhereTagEndsData)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CPlayer >::EachWhereTagContainsData)
|
|
|
|
.Func(_SC("TagMatches"), &Entity< CPlayer >::EachWhereTagMatchesData)
|
|
|
|
.Func(_SC("NameEquals"), &Player_EachWhereNameEqualsData)
|
|
|
|
.Func(_SC("NameBegins"), &Player_EachWhereNameBeginsData)
|
|
|
|
.Func(_SC("NameEnds"), &Player_EachWhereNameEndsData)
|
|
|
|
.Func(_SC("NameContains"), &Player_EachWhereNameContainsData)
|
|
|
|
.Func(_SC("NameMatches"), &Player_EachWhereNameMatchesData)
|
|
|
|
);
|
|
|
|
|
|
|
|
exeach_ns.Bind(_SC("Vehicle"), Table(vm)
|
|
|
|
.Func(_SC("Active"), &Entity< CVehicle >::EachActiveData)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CVehicle >::EachWhereTagEqualsData)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CVehicle >::EachWhereTagBeginsData)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CVehicle >::EachWhereTagEndsData)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CVehicle >::EachWhereTagContainsData)
|
|
|
|
.Func(_SC("TagMatches"), &Entity< CVehicle >::EachWhereTagMatchesData)
|
|
|
|
);
|
|
|
|
|
|
|
|
RootTable(vm).Bind(_SC("SqForeachEx"), exeach_ns);
|
|
|
|
|
2016-07-17 12:33:42 +02:00
|
|
|
Table count_ns(vm);
|
|
|
|
|
|
|
|
count_ns.Bind(_SC("Blip"), Table(vm)
|
|
|
|
.Func(_SC("Active"), &Entity< CBlip >::CountActive)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CBlip >::CountWhereTagEquals)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CBlip >::CountWhereTagBegins)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CBlip >::CountWhereTagEnds)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CBlip >::CountWhereTagContains)
|
2016-08-19 02:49:50 +02:00
|
|
|
.Func(_SC("TagMatches"), &Entity< CBlip >::CountWhereTagMatches)
|
2016-07-17 12:33:42 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
count_ns.Bind(_SC("Checkpoint"), Table(vm)
|
|
|
|
.Func(_SC("Active"), &Entity< CCheckpoint >::CountActive)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CCheckpoint >::CountWhereTagEquals)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CCheckpoint >::CountWhereTagBegins)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CCheckpoint >::CountWhereTagEnds)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CCheckpoint >::CountWhereTagContains)
|
2016-08-19 02:49:50 +02:00
|
|
|
.Func(_SC("TagMatches"), &Entity< CCheckpoint >::CountWhereTagMatches)
|
2016-07-17 12:33:42 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
count_ns.Bind(_SC("Keybind"), Table(vm)
|
|
|
|
.Func(_SC("Active"), &Entity< CKeybind >::CountActive)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CKeybind >::CountWhereTagEquals)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CKeybind >::CountWhereTagBegins)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CKeybind >::CountWhereTagEnds)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CKeybind >::CountWhereTagContains)
|
2016-08-19 02:49:50 +02:00
|
|
|
.Func(_SC("TagMatches"), &Entity< CKeybind >::CountWhereTagMatches)
|
2016-07-17 12:33:42 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
count_ns.Bind(_SC("Object"), Table(vm)
|
|
|
|
.Func(_SC("Active"), &Entity< CObject >::CountActive)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CObject >::CountWhereTagEquals)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CObject >::CountWhereTagBegins)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CObject >::CountWhereTagEnds)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CObject >::CountWhereTagContains)
|
2016-08-19 02:49:50 +02:00
|
|
|
.Func(_SC("TagMatches"), &Entity< CObject >::CountWhereTagMatches)
|
2016-07-17 12:33:42 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
count_ns.Bind(_SC("Pickup"), Table(vm)
|
|
|
|
.Func(_SC("Active"), &Entity< CPickup >::CountActive)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CPickup >::CountWhereTagEquals)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CPickup >::CountWhereTagBegins)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CPickup >::CountWhereTagEnds)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CPickup >::CountWhereTagContains)
|
2016-08-19 02:49:50 +02:00
|
|
|
.Func(_SC("TagMatches"), &Entity< CPickup >::CountWhereTagMatches)
|
2016-07-17 12:33:42 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
count_ns.Bind(_SC("Player"), Table(vm)
|
|
|
|
.Func(_SC("Active"), &Entity< CPlayer >::CountActive)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CPlayer >::CountWhereTagEquals)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CPlayer >::CountWhereTagBegins)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CPlayer >::CountWhereTagEnds)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CPlayer >::CountWhereTagContains)
|
2016-08-19 02:49:50 +02:00
|
|
|
.Func(_SC("TagMatches"), &Entity< CPlayer >::CountWhereTagMatches)
|
2016-07-17 12:33:42 +02:00
|
|
|
.Func(_SC("NameEquals"), &Player_CountWhereNameEquals)
|
|
|
|
.Func(_SC("NameBegins"), &Player_CountWhereNameBegins)
|
|
|
|
.Func(_SC("NameEnds"), &Player_CountWhereNameEnds)
|
|
|
|
.Func(_SC("NameContains"), &Player_CountWhereNameContains)
|
2016-08-19 02:49:50 +02:00
|
|
|
.Func(_SC("NameMatches"), &Player_CountWhereNameMatches)
|
2016-07-17 12:33:42 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
count_ns.Bind(_SC("Vehicle"), Table(vm)
|
|
|
|
.Func(_SC("Active"), &Entity< CVehicle >::CountActive)
|
|
|
|
.Func(_SC("TagEquals"), &Entity< CVehicle >::CountWhereTagEquals)
|
|
|
|
.Func(_SC("TagBegins"), &Entity< CVehicle >::CountWhereTagBegins)
|
|
|
|
.Func(_SC("TagEnds"), &Entity< CVehicle >::CountWhereTagEnds)
|
|
|
|
.Func(_SC("TagContains"), &Entity< CVehicle >::CountWhereTagContains)
|
2016-08-19 02:49:50 +02:00
|
|
|
.Func(_SC("TagMatches"), &Entity< CVehicle >::CountWhereTagMatches)
|
2016-07-17 12:33:42 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
RootTable(vm).Bind(_SC("SqCount"), count_ns);
|
2016-06-21 14:17:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} // Namespace:: Algo
|
2016-06-21 08:02:44 +02:00
|
|
|
|
2016-06-21 14:17:08 +02:00
|
|
|
// ================================================================================================
|
|
|
|
void Register_Algo(HSQUIRRELVM vm)
|
|
|
|
{
|
|
|
|
Algo::Register(vm);
|
|
|
|
}
|
2016-06-21 08:02:44 +02:00
|
|
|
|
|
|
|
} // Namespace:: SqMod
|