Added new ENGINE stocks and natives

This commit is contained in:
David Anderson 2004-03-14 08:23:42 +00:00
parent faafdf9498
commit 5b56c27e67
6 changed files with 611 additions and 7 deletions

View File

@ -32,7 +32,7 @@
* version.
*/
#define VERSION "0.1"
#define VERSION "0.15"
#include <string>
@ -41,7 +41,7 @@ using namespace std;
plugin_info_t Plugin_info = {
META_INTERFACE_VERSION, // ifvers
"Engine", // name
"ENGINE", // name
VERSION, // version
__DATE__, // date
"AMX Mod X Dev Team", // author
@ -53,7 +53,7 @@ plugin_info_t Plugin_info = {
};
module_info_s module_info = {
"Engine", // name
"ENGINE", // name
"AMX Mod X Dev Team", // author
VERSION, // version
AMX_INTERFACE_VERSION,
@ -115,6 +115,8 @@ int thread_fork(void *arg);
#define AMS_OFFSET 0.01
#define GETINFOKEYBUFFER (*g_engfuncs.pfnGetInfoKeyBuffer)
#define SPEAK_NORMAL 0
#define SPEAK_MUTED 1
#define SPEAK_ALL 2
@ -131,6 +133,52 @@ int thread_fork(void *arg);
#define BLOCK_ONCE 1
#define BLOCK_SET 2
//jghg
enum globals {
// Edict
GL_trace_ent = 0,
// Float
GL_coop,
GL_deathmatch,
GL_force_retouch,
GL_found_secrets,
GL_frametime,
GL_serverflags,
GL_teamplay,
GL_time,
GL_trace_allsolid,
GL_trace_fraction,
GL_trace_inopen,
GL_trace_inwater,
GL_trace_plane_dist,
GL_trace_startsolid,
// Int
GL_cdAudioTrack,
GL_maxClients,
GL_maxEntities,
GL_msg_entity,
GL_trace_flags,
GL_trace_hitgroup,
// String
GL_pStringBase,
GL_mapname,
GL_startspot,
// Vector
GL_trace_endpos,
GL_trace_plane_normal,
GL_v_forward,
GL_v_right,
GL_v_up,
GL_vecLandmarkOffset,
// Void (not supported)
GL_pSaveData
};
enum {
gamestate,
oldbuttons,
@ -312,6 +360,7 @@ enum {
arg_entity,
};
//by BAILOPAN
class argStack {
public:
argStack(argStack *p=NULL) //initialize with link to previous

187
dlls/engine/engine.vcproj Executable file
View File

@ -0,0 +1,187 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="engine"
SccProjectName=""
SccLocalPath="">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;ENGINE_EXPORTS"
StringPooling="TRUE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Release/engine.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="release/engine_mm.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
ModuleDefinitionFile=".\engine.def"
ProgramDatabaseFile=".\Release/engine_mm.pdb"
ImportLibrary=".\Release/engine_mm.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\Release/engine.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;ENGINE_EXPORTS"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Debug/engine.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile=".\Debug/engine.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
ModuleDefinitionFile=".\engine.def"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\Debug/engine.pdb"
ImportLibrary=".\Debug/engine.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\Debug/engine.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl">
<File
RelativePath="engine.h">
</File>
<File
RelativePath="meta_api.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;ENGINE_EXPORTS;$(NoInherit)"
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;ENGINE_EXPORTS;$(NoInherit)"
BasicRuntimeChecks="3"/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
<File
RelativePath="engine.def">
</File>
<File
RelativePath="engine.inc">
</File>
</Filter>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -50,8 +50,43 @@ GlobalInfo GlInfo;
MessageInfo *msgd;
bool isMsgHooked[MAX_MESSAGES];
int inHookProcess;
edict_t *valid_ent(int ent);
edict_t *valid_player(int ent);
cvar_t amxxe_version = {"amxxe_version", VERSION, FCVAR_SERVER, 0};
void UTIL_SetSize(edict_t *pev, const Vector &vecMin, const Vector &vecMax)
{
SET_SIZE(ENT(pev), vecMin, vecMax);
}
edict_t *valid_player(int ent)
{
if (ent < 1 || ent > gpGlobals->maxClients) {
return NULL;
}
edict_t *e = INDEXENT(ent);
if (FNullEnt(e)) {
return NULL;
}
return e;
}
edict_t *valid_ent(int ent)
{
if (ent < 1 || ent > gpGlobals->maxEntities) {
return NULL;
}
edict_t *e = INDEXENT(ent);
if (FNullEnt(e)) {
return NULL;
}
return e;
}
//from OLO
char* get_amxstring(AMX *amx,cell amx_addr,int id, int& len)
@ -2408,6 +2443,252 @@ static cell AMX_NATIVE_CALL precache_generic(AMX *amx, cell *params)
return 1;
}
//ported from jghg2
static cell AMX_NATIVE_CALL drop_to_floor(AMX *amx, cell *params)
{
int iEnt = params[1];
edict_t* e = valid_ent(iEnt);
if (e!=NULL) {
return DROP_TO_FLOOR(e);
}
return -1;
}
static cell AMX_NATIVE_CALL get_info_keybuffer(AMX *amx, cell *params)
{
int iEnt = params[1];
edict_t *e = valid_ent(iEnt);
if (e!=NULL) {
char *info = GETINFOKEYBUFFER(e);
return SET_AMXSTRING(amx, params[2], info, params[3]);
} else {
return 0;
}
}
static cell AMX_NATIVE_CALL force_use(AMX *amx, cell *params)
{
int pev = params[1];
int ent = params[2];
edict_t *pPlayer = valid_player(pev);
edict_t *pEntity = valid_ent(ent);
MDLL_Use(pEntity, pPlayer);
return 1;
}
static cell AMX_NATIVE_CALL get_global_float(AMX *amx, cell *params)
{
int global = params[1];
float returnValue;
switch (params[1]) {
case GL_coop:
returnValue = gpGlobals->coop;
break;
case GL_deathmatch:
returnValue = gpGlobals->deathmatch;
break;
case GL_force_retouch:
returnValue = gpGlobals->force_retouch;
break;
case GL_found_secrets:
returnValue = gpGlobals->found_secrets;
break;
case GL_frametime:
returnValue = gpGlobals->frametime;
break;
case GL_serverflags:
returnValue = gpGlobals->serverflags;
break;
case GL_teamplay:
returnValue = gpGlobals->teamplay;
break;
case GL_time:
returnValue = gpGlobals->time;
break;
case GL_trace_allsolid:
returnValue = gpGlobals->trace_allsolid;
break;
case GL_trace_fraction:
returnValue = gpGlobals->trace_fraction;
break;
case GL_trace_inopen:
returnValue = gpGlobals->trace_inopen;
break;
case GL_trace_inwater:
returnValue = gpGlobals->trace_inwater;
break;
case GL_trace_plane_dist:
returnValue = gpGlobals->trace_plane_dist;
break;
case GL_trace_startsolid:
returnValue = gpGlobals->trace_startsolid;
break;
default:
AMX_RAISEERROR(amx, AMX_ERR_NATIVE);
return 0;
}
return *(cell*)((void *)&returnValue);
}
static cell AMX_NATIVE_CALL get_global_int(AMX *amx, cell *params)
{
int returnValue = 0;
switch (params[1]) {
case GL_cdAudioTrack:
returnValue = gpGlobals->cdAudioTrack;
break;
case GL_maxClients:
returnValue = gpGlobals->maxClients;
break;
case GL_maxEntities:
returnValue = gpGlobals->maxEntities;
break;
case GL_msg_entity:
returnValue = gpGlobals->msg_entity;
break;
case GL_trace_flags:
returnValue = gpGlobals->trace_flags;
break;
case GL_trace_hitgroup:
returnValue = gpGlobals->trace_hitgroup;
break;
default:
AMX_RAISEERROR(amx, AMX_ERR_NATIVE);
return 0;
}
}
static cell AMX_NATIVE_CALL get_global_string(AMX *amx, cell *params)
{
string_t* returnValue;
switch(params[1]) {
case GL_pStringBase: // const char *, so no string_t
return SET_AMXSTRING(amx, params[2], gpGlobals->pStringBase, params[3]);
// The rest are string_t:s...
case GL_mapname:
returnValue = &(gpGlobals->mapname);
break;
case GL_startspot:
returnValue = &(gpGlobals->startspot);
break;
default:
AMX_RAISEERROR(amx, AMX_ERR_NATIVE);
return 0;
}
return SET_AMXSTRING(amx, params[2], STRING(*returnValue), params[3]);
}
static cell AMX_NATIVE_CALL get_global_vector(AMX *amx, cell *params) // globals_get_vector(variable, Float:vector[3]); = 2 params
{
cell *returnVector = GET_AMXADDR(amx, params[2]);
vec3_t fetchedVector;
switch (params[1]) {
case GL_trace_endpos:
fetchedVector = gpGlobals->trace_endpos;
break;
case GL_trace_plane_normal:
fetchedVector = gpGlobals->trace_plane_normal;
break;
case GL_v_forward:
fetchedVector = gpGlobals->v_forward;
break;
case GL_v_right:
fetchedVector = gpGlobals->v_right;
break;
case GL_v_up:
fetchedVector = gpGlobals->v_up;
break;
case GL_vecLandmarkOffset:
fetchedVector = gpGlobals->vecLandmarkOffset;
break;
default:
AMX_RAISEERROR(amx, AMX_ERR_NATIVE);
return 0;
}
returnVector[0] = *(cell*)((void *)&fetchedVector.x);
returnVector[1] = *(cell*)((void *)&fetchedVector.y);
returnVector[2] = *(cell*)((void *)&fetchedVector.z);
return 1;
}
static cell AMX_NATIVE_CALL get_global_edict(AMX *amx, cell *params) // globals_get_edict(variable); = 1 param
{
edict_t* pReturnEntity;
switch (params[1]) {
case GL_trace_ent:
pReturnEntity = gpGlobals->trace_ent;
break;
default:
AMX_RAISEERROR(amx, AMX_ERR_NATIVE);
return 0;
}
// Will crash if ENTINDEX() is called on bad pointer?
if(!FNullEnt(pReturnEntity))
return ENTINDEX(pReturnEntity);
return 0;
}
static cell AMX_NATIVE_CALL precache_event(AMX *amx, cell *params)
{
int len;
char *szEvent = FORMAT_AMXSTRING(amx, params, 2, len);
PRECACHE_EVENT(params[1], (char *)STRING(ALLOC_STRING(szEvent)));
return 1;
}
static cell AMX_NATIVE_CALL get_decal_index(AMX *amx, cell *params)
{
int len;
char *szDecal = GET_AMXSTRING(amx, params[1], 0, len);
return DECAL_INDEX(szDecal);
}
static cell AMX_NATIVE_CALL set_size(AMX *amx, cell *params)
{
int ent = params[1];
edict_t *e = valid_ent(ent);
if (e == NULL) {
return 0;
}
cell *cMin = GET_AMXADDR(amx, params[2]);
float x1 = *(float *)((void *)&cMin[0]);
float y1 = *(float *)((void *)&cMin[1]);
float z1 = *(float *)((void *)&cMin[2]);
Vector vMin = Vector(x1, y1, z1);
cell *cMax = GET_AMXADDR(amx, params[3]);
float x2 = *(float *)((void *)&cMax[0]);
float y2 = *(float *)((void *)&cMax[1]);
float z2 = *(float *)((void *)&cMax[2]);
Vector vMax = Vector(x2, y2, z2);
UTIL_SetSize(e, vMin, vMax);
return 1;
}
/********************************************
METAMOD HOOKED FUNCTIONS
*****************************************/
@ -2592,7 +2873,7 @@ BOOL ClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress
//(vexd)
void GameInit(void) {
CVAR_REGISTER(&amxxe_version);
}
// make sure that if we currently have an edited light value, to use it.
@ -3093,6 +3374,17 @@ AMX_NATIVE_INFO Engine_Natives[] = {
{"get_msg_args", get_msg_args},
{"get_msg_argtype", get_msg_argtype},
{"is_valid_ent", is_valid_ent},
{"drop_to_floor", drop_to_floor},
{"get_info_keybuffer", get_info_keybuffer},
{"force_use", force_use},
{"get_global_float", get_global_float},
{"get_global_int", get_global_int},
{"get_global_string", get_global_string},
{"get_global_edict", get_global_edict},
{"get_global_vector", get_global_vector},
{"set_size", set_size},
{"get_decal_index", get_decal_index},
{"precache_event", precache_event},
{ NULL, NULL }

View File

@ -39,7 +39,7 @@ native register_message(iMsgId, szFunction[]);
/* The get/set _msg commands will utterly fail if used outside a hooked message scope.
* They should never, NEVER, EVER be used unless inside a registered message function.
* There are eight different ways of sending a message, five are ints, two are floats, and one is string.
* These are denoted by iArgType. msg_tid is the message you are hooking. argn is the number
* These are denoted by iArgType. argn is the number
* of the argument. Exceeding the bounds of 1 to get_msg_args() is a bad idea. */
/* Gets number of arguments that were passed to this message */
@ -74,6 +74,31 @@ native set_offset_short(id, offset);
/* Precaches any file. */
native precache_generic(szFile[]);
/* Precaches an event. */
native precache_event(type, Name[], {float,_}:...);
//Drops an entity to the floor (work?)
native drop_to_floor(entity)
/* Get whole buffer containing keys and their data. */
native get_info_keybuffer(id, buffer[], length);
/* Use an entity with another entity. "used" could be a hostage, "user" a player. */
native force_use(pPlayer, pEntity);
/* Get globals from server. */
native Float:get_global_float(variable);
native get_global_int(variable);
native get_global_string(variable, string[], maxlen);
native get_global_vector(variable, Float:vector[3]);
native get_global_edict(variable);
/* Set entity bounds. */
native set_size(index, Float:mins[3], Float:maxs[3]);
/* Get decal index */
native get_decal_index(const szDecalName[]);
/* Sets/gets things in an entities Entvars Struct. */
native entity_get_int(iIndex, iKey);

View File

@ -307,4 +307,49 @@ enum {
#define EF_INVLIGHT 16 /* get lighting from ceiling */
#define EF_NOINTERP 32 /* don't interpolate the next frame */
#define EF_LIGHT 64 /* rocket flare glow sprite */
#define EF_NODRAW 128 /* don't draw entity */
#define EF_NODRAW 128 /* don't draw entity */
enum {
// Edict
GL_trace_ent = 0,
// Float
GL_coop,
GL_deathmatch,
GL_force_retouch,
GL_found_secrets,
GL_frametime,
GL_serverflags,
GL_teamplay,
GL_time,
GL_trace_allsolid,
GL_trace_fraction,
GL_trace_inopen,
GL_trace_inwater,
GL_trace_plane_dist,
GL_trace_startsolid,
// Int
GL_cdAudioTrack,
GL_maxClients,
GL_maxEntities,
GL_msg_entity,
GL_trace_flags,
GL_trace_hitgroup,
// String
GL_pStringBase,
GL_mapname,
GL_startspot,
// Vector
GL_trace_endpos,
GL_trace_plane_normal,
GL_v_forward,
GL_v_right,
GL_v_up,
GL_vecLandmarkOffset,
// Void (not supported)
GL_pSaveData
}

View File

@ -11,6 +11,12 @@
#endif
#define _engine_stocks_included
//wrapper for find_ent_by_class
stock find_ent(iStart, szClassname[])
{
return find_ent_by_classname(iStart, szClassname)
}
/* Changes an integer vec to a floating vec */
stock IVecFVec(IVec[3], Float:FVec[3])